my code is here:
use utils::schema::users::dsl::*;
let user_result = users.filter(&username.eq(&signin_user.username)).load::<User>(&self.0);
let login_user = match user_result {
Ok(ref user_some) => match user_some.first() {
Some(a_user) => Some(a_user.clone()),
None => None,
},
Err(_) => None,
};
let no_user = User {
id: 0,
email: "".to_owned(),
username: "".to_owned(),
password: "".to_owned(),
time : SystemTime::now(),
};
match login_user {
Some(login_user) => {
match verify(&signin_user.password, &login_user.password) {
Ok(valid) => {
let user_id = login_user.id.to_string();
let token = token::generate_token(user_id).unwrap();
Ok(SigninMsgs {
status: 200,
token: token,
signin_user: *login_user,
message : "Succesfully signin.".to_string(),
})
},
Err(_) => {
Ok(SigninMsgs {
status: 400,
token: "".to_owned(),
signin_user: no_user,
message : "Incorrect Password.".to_string(),
})
},
}
},
None => {
Ok(SigninMsgs {
status: 400,
token: "".to_owned(),
signin_user: no_user,
message : "Signin failure.".to_string(),
})
}
}
when 'cargo run' , I get the error:
error[E0507]: cannot move out of borrowed content
--> src/handler/func.rs:78:42
|
78 | signin_user: *login_user,
| ^^^^^^^^^^^ cannot move out of borrowed content
error: aborting due to previous error
How can i get the 'login_user' ?
1
共 0 条评论, 1 页
评论区
写评论还没有评论