Add token authentication for controllers
This commit is contained in:
parent
faacdc8c83
commit
e2dc5f8857
3 changed files with 9 additions and 0 deletions
|
|
@ -15,6 +15,7 @@ use crate::types::EmgauwaUid;
|
|||
#[derive(Debug)]
|
||||
pub enum EmgauwaError {
|
||||
Api(ApiError),
|
||||
Unauthorized(String),
|
||||
Uid(uuid::Error),
|
||||
Serialization(serde_json::Error),
|
||||
Database(DatabaseError),
|
||||
|
|
@ -28,6 +29,7 @@ impl EmgauwaError {
|
|||
fn get_code(&self) -> StatusCode {
|
||||
match self {
|
||||
EmgauwaError::Api(err) => err.get_code(),
|
||||
EmgauwaError::Unauthorized(_) => StatusCode::UNAUTHORIZED,
|
||||
EmgauwaError::Serialization(_) => StatusCode::INTERNAL_SERVER_ERROR,
|
||||
EmgauwaError::Database(err) => err.get_code(),
|
||||
EmgauwaError::Uid(_) => StatusCode::BAD_REQUEST,
|
||||
|
|
@ -43,6 +45,7 @@ impl From<&EmgauwaError> for String {
|
|||
fn from(err: &EmgauwaError) -> Self {
|
||||
match err {
|
||||
EmgauwaError::Api(err) => String::from(err),
|
||||
EmgauwaError::Unauthorized(_) => format!("unauthorized request: {}", err),
|
||||
EmgauwaError::Serialization(_) => String::from("error during (de-)serialization"),
|
||||
EmgauwaError::Database(err) => String::from(err),
|
||||
EmgauwaError::Uid(_) => String::from("the uid is in a bad format"),
|
||||
|
|
|
|||
Loading…
Reference in a new issue