Added a user system with no proper user validation but working authorisation. #1
@ -147,18 +147,18 @@ pub async fn login(conn: DbConn, login: Login) -> Result<LoginResult, DatabaseEr
|
||||
.filter(user::username.eq(&login.username))
|
||||
.or_filter(user::email.eq(&login.username))
|
||||
.select(user::id)
|
||||
.get_results(c)
|
||||
.first(c)
|
||||
{
|
||||
Ok(id) => id[0],
|
||||
Ok(id) => id,
|
||||
Roflin marked this conversation as resolved
Outdated
|
||||
Err(error) => return Err(DatabaseError::Query(error.to_string())),
|
||||
};
|
||||
|
||||
let pwd: String = match pwd::table
|
||||
.filter(pwd::user_id.eq(id))
|
||||
.select(pwd::password)
|
||||
.get_results::<String>(c)
|
||||
.first(c)
|
||||
{
|
||||
Ok(pwd) => pwd[0].clone(),
|
||||
Ok(pwd) => pwd,
|
||||
Err(error) => return Err(DatabaseError::Query(error.to_string())),
|
||||
};
|
||||
|
||||
@ -174,9 +174,9 @@ pub async fn login(conn: DbConn, login: Login) -> Result<LoginResult, DatabaseEr
|
||||
let role: Role = match user::table
|
||||
.filter(user::id.eq(id))
|
||||
.select(user::role)
|
||||
.get_results::<Role>(c)
|
||||
.first(c)
|
||||
{
|
||||
Ok(role) => role[0].clone(),
|
||||
Ok(role) => role,
|
||||
Err(error) => return Err(DatabaseError::Query(error.to_string())),
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user
generates a panic if the user does not exist