Daniel García
					
					6 years ago
					
				 
				
			 
		 
		
			
				
					
					No known key found for this signature in database
					
						
							GPG Key ID: FC8A7D14C3CD543A
						
					
				
			
		
		
		
	
		
			
				 2 changed files with 
16 additions and 
5 deletions
			 
			
		 
		
			
				- 
					
					
					 
					src/api/identity.rs
				
 
			
				- 
					
					
					 
					src/error.rs
				
 
			
		
		
			
			
			
			
			
			
				
				
					
						
							
								
									
	
		
			
				
					| 
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -211,7 +211,7 @@ fn twofactor_auth( | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    let twofactor_code = match data.two_factor_token { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        Some(ref code) => code, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        None => err_json!(_json_err_twofactor(&twofactor_ids, user_uuid, conn)?), | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        None => err_json!(_json_err_twofactor(&twofactor_ids, user_uuid, conn)?, "2FA token not provided"), | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    }; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    let selected_twofactor = twofactors | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				
					@ -237,7 +237,7 @@ fn twofactor_auth( | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                Some(ref code) if !CONFIG.disable_2fa_remember() && ct_eq(code, twofactor_code) => { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    remember = 1; // Make sure we also return the token here, otherwise it will only remember the first time
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                _ => err_json!(_json_err_twofactor(&twofactor_ids, user_uuid, conn)?), | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                _ => err_json!(_json_err_twofactor(&twofactor_ids, user_uuid, conn)?, "2FA Remember token not provided"), | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        _ => err!("Invalid two factor provider"), | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
				
				 | 
				
					
  | 
				
			
			
		
	
								
							
						
					 
					
				 
			 
		
			
			
			
			
			
			
				
				
					
						
							
								
									
	
		
			
				
					| 
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -86,7 +86,18 @@ impl std::fmt::Debug for Error { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        match self.source() { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            Some(e) => write!(f, "{}.\n[CAUSE] {:#?}", self.message, e), | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            None => write!(f, "{}", self.message), | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            None => match self.error { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                ErrorKind::EmptyError(_) => Ok(()), | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                ErrorKind::SimpleError(ref s) => { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    if &self.message == s { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        write!(f, "{}", self.message) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    } else { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        write!(f, "{}. {}", self.message, s) | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                }, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                ErrorKind::JsonError(_) => write!(f, "{}", self.message), | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                _ => unreachable!(), | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            }, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					} | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -200,8 +211,8 @@ macro_rules! err { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					#[macro_export] | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					macro_rules! err_json { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    ($expr:expr) => {{ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        return Err(crate::error::Error::from($expr)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    ($expr:expr, $log_value:expr) => {{ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        return Err(($log_value, $expr).into()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    }}; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					} | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
				
				 | 
				
					
  |