[][src]Struct sudoku_backend::ops::LoginForm

pub struct LoginForm {
    pub login: Result<NonEmpty, ()>,
    pub password: Result<HexString<SCrypt64Length>, Option<Option<usize>>>,
    pub email: Option<Result<EMail, Option<&'static str>>>,
    pub ext_error: Result<(), (Cow<'static, str>, bool)>,
}

Log-in and user-create form – refer to doc/user.md.

Examples

#[post("/login", data="<form>")]
fn login(db: DatabaseConnection, form: Form<LoginForm>)
    -> Result<String, Result<Json<GenericError>, Json<LoginError>>>
{
    let (user_id, is_admin) = form.into_inner().validate(&db).map_err(|e| Err(Json(e)))?;
    work(&db, user_id, is_admin).map_err(|e| Ok(Json(e)))
}

fn main() {
    let database_file: (String, PathBuf) = /* obtained elsewhere */;
    rocket::ignite()
        .manage(DatabaseConnection::initialise(&database_file))
        .mount("/", routes![login])
        .launch();
}

Fields

Username, non-empty.

Scrypted user password, constant width.

User's e-mail. Need exist for user creation.

Error parsing the box, see doc/user.md.

Methods

impl LoginForm
[src]

Get a list of errors.

Only applicable if password couldn't be parsed.

Attempt to log the user in with the stored login and password.

Returns user's (id, is_admin) on success.

Attempt the conversion to a User.

Returns self, optionally with an additional error, on error.

Trait Implementations

impl PartialEq<LoginForm> for LoginForm
[src]

impl Clone for LoginForm
[src]

Performs copy-assignment from source. Read more

impl From<User> for LoginForm
[src]

impl Ord for LoginForm
[src]

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

impl Eq for LoginForm
[src]

impl PartialOrd<LoginForm> for LoginForm
[src]

impl Debug for LoginForm
[src]

impl<'f> FromForm<'f> for LoginForm
[src]

The associated error to be returned when parsing fails.

Auto Trait Implementations

impl Send for LoginForm

impl Sync for LoginForm

Blanket Implementations

impl<T> From for T
[src]

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

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

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

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

The type returned in the event of a conversion error.

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

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

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

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

The type returned in the event of a conversion error.

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

impl<T> Typeable for T where
    T: Any
[src]

Get the TypeId of this object.

impl<T> IntoSql for T
[src]

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

Convert &self to an expression for Diesel's query builder. Read more