Struct actix_identity::Identity[][src]

pub struct Identity(_);
Expand description

The extractor type to obtain your identity from a request.

use actix_web::*;
use actix_identity::Identity;

fn index(id: Identity) -> Result<String> {
    // access request identity
    if let Some(id) = id.identity() {
        Ok(format!("Welcome! {}", id))
    } else {
        Ok("Welcome Anonymous!".to_owned())
    }
}

fn login(id: Identity) -> HttpResponse {
    id.remember("User1".to_owned()); // <- remember identity
    HttpResponse::Ok().finish()
}

fn logout(id: Identity) -> HttpResponse {
    id.forget(); // <- remove identity
    HttpResponse::Ok().finish()
}

Implementations

Return the claimed identity of the user associated request or None if no identity can be found associated with the request.

Remember identity.

This method is used to ‘forget’ the current identity on subsequent requests.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Extractor implementation for Identity type.

use actix_identity::Identity;

fn index(id: Identity) -> String {
    // access request identity
    if let Some(id) = id.identity() {
        format!("Welcome! {}", id)
    } else {
        "Welcome Anonymous!".to_owned()
    }
}

Configuration for this extractor

The associated error which can be returned.

Future that resolves to a Self

Convert request to a Self

Convert request to a Self Read more

Create and configure config instance.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

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

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

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

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

Performs the conversion.

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

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

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