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
.
#[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) = ;
rocket::ignite()
.manage(DatabaseConnection::initialise(&database_file))
.mount("/", routes![login])
.launch();
}
Scrypted user password, constant width.
User's e-mail. Need exist for user creation.
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.
This method tests for self
and other
values to be equal, and is used by ==
. Read more
This method tests for !=
.
Performs copy-assignment from source
. Read more
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self | 1.21.0 [src] |
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self | 1.21.0 [src] |
Compares and returns the minimum of two values. Read more
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
Formats the value using the given formatter. Read more
The associated error to be returned when parsing fails.
Parses an instance of Self
from the iterator of form items it
. Read more
Creates owned data from borrowed data, usually by cloning. Read more
🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
Immutably borrows from an owned value. Read more
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
Mutably borrows from an owned value. Read more
Get the TypeId
of this object.
Convert self
to an expression for Diesel's query builder. Read more
Convert &self
to an expression for Diesel's query builder. Read more