Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fn login_to_auth(username: String, password: String) -> Result<Authentication, String> {
- // unimplemented!();
- let vu: Vec<&str> = username.split(':').collect();
- match *vu {
- [] => Err(String::from("Comprend pas")),
- [login] => Ok(Authentication::Login {
- username: login.to_string(),
- password: password.to_string(),
- }),
- [auth_type, imei, idtel] if auth_type == "ident" => Ok(Authentication::Ident {
- imei: imei.to_string(),
- idtel: idtel.to_string(),
- }),
- [auth_type, imei, idtel] if auth_type == "auth" => {
- let vt: Vec<&str> = password.split(':').collect();
- match *vt {
- [uid, token] => Ok(Authentication::Token {
- uid: uid.to_string(),
- token: token.to_string(),
- imei: imei.to_string(),
- idtel: idtel.to_string(),
- }),
- _ => Err(String::from(format!(
- "this imei {} is trying to use a password {} that is not a token.",
- imei, password
- ))),
- }
- }
- _ => Err(String::from("I don't understand the username chain.")),
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement