style: clippy & fmt
This commit is contained in:
parent
6783bd22a7
commit
8163d0d9c0
4 changed files with 18 additions and 9 deletions
|
@ -8,7 +8,7 @@ use crate::{
|
||||||
schema::refresh_tokens::{self, dsl},
|
schema::refresh_tokens::{self, dsl},
|
||||||
};
|
};
|
||||||
|
|
||||||
/// `GET /api/v1/logout`
|
/// `GET /api/v1/logout`
|
||||||
///
|
///
|
||||||
/// requires auth: kinda, needs refresh token set but no access token is technically required
|
/// requires auth: kinda, needs refresh token set but no access token is technically required
|
||||||
///
|
///
|
||||||
|
@ -18,11 +18,10 @@ use crate::{
|
||||||
/// 401 Unauthorized (no refresh token found)
|
/// 401 Unauthorized (no refresh token found)
|
||||||
///
|
///
|
||||||
#[post("/logout")]
|
#[post("/logout")]
|
||||||
pub async fn res(
|
pub async fn res(req: HttpRequest, data: web::Data<Data>) -> Result<HttpResponse, Error> {
|
||||||
req: HttpRequest,
|
let mut refresh_token_cookie = req.cookie("refresh_token").ok_or(Error::Unauthorized(
|
||||||
data: web::Data<Data>,
|
"request has no refresh token".to_string(),
|
||||||
) -> Result<HttpResponse, Error> {
|
))?;
|
||||||
let mut refresh_token_cookie = req.cookie("refresh_token").ok_or(Error::Unauthorized("request has no refresh token".to_string()))?;
|
|
||||||
|
|
||||||
let refresh_token = String::from(refresh_token_cookie.value());
|
let refresh_token = String::from(refresh_token_cookie.value());
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,9 @@ use super::Response;
|
||||||
|
|
||||||
#[post("/refresh")]
|
#[post("/refresh")]
|
||||||
pub async fn res(req: HttpRequest, data: web::Data<Data>) -> Result<HttpResponse, Error> {
|
pub async fn res(req: HttpRequest, data: web::Data<Data>) -> Result<HttpResponse, Error> {
|
||||||
let mut refresh_token_cookie = req.cookie("refresh_token").ok_or(Error::Unauthorized("request has no refresh token".to_string()))?;
|
let mut refresh_token_cookie = req.cookie("refresh_token").ok_or(Error::Unauthorized(
|
||||||
|
"request has no refresh token".to_string(),
|
||||||
|
))?;
|
||||||
|
|
||||||
let mut refresh_token = String::from(refresh_token_cookie.value());
|
let mut refresh_token = String::from(refresh_token_cookie.value());
|
||||||
|
|
||||||
|
|
|
@ -87,7 +87,11 @@ impl ConfigBuilder {
|
||||||
ip: self.web.ip.unwrap_or(String::from("0.0.0.0")),
|
ip: self.web.ip.unwrap_or(String::from("0.0.0.0")),
|
||||||
port: self.web.port.unwrap_or(8080),
|
port: self.web.port.unwrap_or(8080),
|
||||||
frontend_url: self.web.frontend_url.clone(),
|
frontend_url: self.web.frontend_url.clone(),
|
||||||
backend_url: self.web.backend_url.or_else(|| self.web.frontend_url.join("/api").ok()).unwrap(),
|
backend_url: self
|
||||||
|
.web
|
||||||
|
.backend_url
|
||||||
|
.or_else(|| self.web.frontend_url.join("/api").ok())
|
||||||
|
.unwrap(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let endpoint = match &*self.bunny.endpoint {
|
let endpoint = match &*self.bunny.endpoint {
|
||||||
|
|
|
@ -16,7 +16,11 @@ use serde::Serialize;
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
config::Config, error::Error, schema::users, structs::{HasIsAbove, HasUuid}, Conn, Data
|
Conn, Data,
|
||||||
|
config::Config,
|
||||||
|
error::Error,
|
||||||
|
schema::users,
|
||||||
|
structs::{HasIsAbove, HasUuid},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub static EMAIL_REGEX: LazyLock<Regex> = LazyLock::new(|| {
|
pub static EMAIL_REGEX: LazyLock<Regex> = LazyLock::new(|| {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue