Struct rocket_auth::User[][src]

pub struct User {
    pub id: u32,
    pub email: String,
    pub is_admin: bool,
    // some fields omitted
}

The User guard can be used to restrict content so it can only be viewed my authenticated users.

#[get("/private-content/")]
fn private_content(user: User) -> &'static str {
    "If you can see this, you are logged in."
}

Fields

id: u32email: Stringis_admin: bool

Implementations

impl User[src]

pub fn reset_password(&mut self, new: &str) -> Result<(), Error>[src]

This method allows to reset the password of a user. In order for the new password to be saved, it must be passed to a Users instance. This function is meant for cases where the user lost their password. In case the user is authenticated, you can change it more easily with change_password. This function will fail in case the password is not secure enough.

#[get("/reset-password/<id>/<new_password>")]
fn reset_password(id: u32, new_password: String, users: State<Users>) -> Result<()> {
    let mut user = users.get_by_id(id);
    user.reset_password();
    users.modify(user)?;
    Ok(())
}

Trait Implementations

impl Clone for User[src]

impl Debug for User[src]

impl<'de> Deserialize<'de> for User[src]

impl Eq for User[src]

impl<'a, 'r> FromRequest<'a, 'r> for User[src]

type Error = Error

The associated error to be returned if derivation fails.

impl PartialEq<User> for User[src]

impl Serialize for User[src]

impl StructuralEq for User[src]

impl StructuralPartialEq for User[src]

Auto Trait Implementations

impl RefUnwindSafe for User

impl Send for User

impl Sync for User

impl Unpin for User

impl UnwindSafe for User

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T, I> AsResult<T, I> for T where
    I: Input, 

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

impl<T> Erased for T

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> IntoCollection<T> for T

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Typeable for T where
    T: Any

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