pub struct FormLoginService<A>where
A: CredentialAuthenticator + Clone,{ /* private fields */ }Expand description
Complete form login service combining authentication and session management.
§Example
ⓘ
let service = FormLoginService::new(
memory_authenticator,
FormLoginConfig::new(),
SessionConfig::new(),
);
// In login handler
async fn login(
session: Session,
form: Form<LoginForm>,
service: Data<FormLoginService<MemoryAuthenticator>>,
) -> impl Responder {
service.attempt_authentication(&session, &form.username, &form.password)
}Implementations§
Source§impl<A> FormLoginService<A>where
A: CredentialAuthenticator + Clone,
impl<A> FormLoginService<A>where
A: CredentialAuthenticator + Clone,
Sourcepub fn new(
authenticator: A,
config: FormLoginConfig,
session_config: SessionConfig,
) -> FormLoginService<A>
pub fn new( authenticator: A, config: FormLoginConfig, session_config: SessionConfig, ) -> FormLoginService<A>
Create a new form login service.
Sourcepub fn attempt_authentication(
&self,
session: &Session,
username: &str,
password: &str,
) -> HttpResponse
pub fn attempt_authentication( &self, session: &Session, username: &str, password: &str, ) -> HttpResponse
Attempt authentication with username and password.
Returns an HTTP response (redirect to success or failure URL).
Sourcepub fn attempt_authentication_with_form(
&self,
session: &Session,
form: &LoginForm,
) -> HttpResponse
pub fn attempt_authentication_with_form( &self, session: &Session, form: &LoginForm, ) -> HttpResponse
Attempt authentication with login form data.
Sourcepub fn logout(&self, session: &Session) -> HttpResponse
pub fn logout(&self, session: &Session) -> HttpResponse
Handle logout.
Sourcepub fn handler(&self) -> &FormLoginHandler
pub fn handler(&self) -> &FormLoginHandler
Get the form login handler.
Sourcepub fn authenticator(&self) -> &A
pub fn authenticator(&self) -> &A
Get the authenticator.
Trait Implementations§
Source§impl<A> Clone for FormLoginService<A>where
A: Clone + CredentialAuthenticator,
impl<A> Clone for FormLoginService<A>where
A: Clone + CredentialAuthenticator,
Source§fn clone(&self) -> FormLoginService<A>
fn clone(&self) -> FormLoginService<A>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl<A> Freeze for FormLoginService<A>where
A: Freeze,
impl<A> RefUnwindSafe for FormLoginService<A>where
A: RefUnwindSafe,
impl<A> Send for FormLoginService<A>
impl<A> Sync for FormLoginService<A>
impl<A> Unpin for FormLoginService<A>where
A: Unpin,
impl<A> UnwindSafe for FormLoginService<A>where
A: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more