mahjong_service::auth

Struct AuthHandler

source
pub struct AuthHandler<'a> { /* private fields */ }

Implementations§

source§

impl<'a> AuthHandler<'a>

source

pub fn verify_setup() -> bool

source

pub fn new(storage: &'a DataStorage, req: &'a HttpRequest) -> Self

source

pub async fn validate_email_user( &mut self, username: &String, password: &String, ) -> Result<Option<bool>, String>

source

pub async fn validate_anon_user( &mut self, id_token: &String, ) -> Result<Option<bool>, UnauthorizedError>

source

pub async fn create_email_user( &mut self, username: &Username, password: &String, role: UserRole, ) -> Result<(), String>

source

pub async fn create_anonymous_user( &mut self, token: &String, role: UserRole, ) -> Result<(), String>

source

pub async fn create_github_user( &mut self, username: &Username, token: &str, role: UserRole, ) -> Result<(), String>

source

pub fn generate_token(&self) -> Result<UserPostSetAuthResponse, String>

source

pub fn verify_user(&self, player_id: &PlayerId) -> Result<(), UnauthorizedError>

source

pub fn get_user_from_token(&self) -> Result<String, UnauthorizedError>

source

pub fn verify_user_token(&self, player_id: &PlayerId, token: &String) -> bool

source

pub fn verify_admin(&self) -> Result<(), UnauthorizedError>

source

pub fn verify_admin_token(&self, token: &String) -> bool

source

pub fn get_unauthorized() -> HttpResponse

source

pub async fn get_auth_info_summary( &self, ) -> Result<AuthInfoSummary, AuthInfoSummaryError>

Auto Trait Implementations§

§

impl<'a> Freeze for AuthHandler<'a>

§

impl<'a> !RefUnwindSafe for AuthHandler<'a>

§

impl<'a> !Send for AuthHandler<'a>

§

impl<'a> !Sync for AuthHandler<'a>

§

impl<'a> Unpin for AuthHandler<'a>

§

impl<'a> !UnwindSafe for AuthHandler<'a>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> IntoSql for T

§

fn into_sql<T>(self) -> Self::Expression
where Self: Sized + AsExpression<T>, T: SqlType + TypedExpressionType,

Convert self to an expression for Diesel’s query builder. Read more
§

fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
where &'a Self: AsExpression<T>, T: SqlType + TypedExpressionType,

Convert &self to an expression for Diesel’s query builder. Read more
source§

impl<T> Same for T

source§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more