adaptions
This commit is contained in:
		
					parent
					
						
							
								2248850f78
							
						
					
				
			
			
				commit
				
					
						b67e488236
					
				
			
		
					 3 changed files with 24 additions and 19 deletions
				
			
		|  | @ -45,8 +45,8 @@ class Index extends BaseSettings | |||
| 		try { | ||||
| 			User::getIdFromPasswordAuthentication(local_user(), $_POST['password'] ?? ''); | ||||
| 
 | ||||
| 			$has_secret = (bool) DI::pConfig()->get(local_user(), '2fa', 'secret'); | ||||
| 			$verified = DI::pConfig()->get(local_user(), '2fa', 'verified'); | ||||
| 			$has_secret = (bool)DI::pConfig()->get(local_user(), '2fa', 'secret'); | ||||
| 			$verified   = DI::pConfig()->get(local_user(), '2fa', 'verified'); | ||||
| 
 | ||||
| 			switch ($_POST['action'] ?? '') { | ||||
| 				case 'enable': | ||||
|  | @ -55,7 +55,8 @@ class Index extends BaseSettings | |||
| 
 | ||||
| 						DI::pConfig()->set(local_user(), '2fa', 'secret', $Google2FA->generateSecretKey(32)); | ||||
| 
 | ||||
| 						DI::baseUrl()->redirect('settings/2fa/recovery?t=' . self::getFormSecurityToken('settings_2fa_password')); | ||||
| 						DI::baseUrl() | ||||
| 						  ->redirect('settings/2fa/recovery?t=' . self::getFormSecurityToken('settings_2fa_password')); | ||||
| 					} | ||||
| 					break; | ||||
| 				case 'disable': | ||||
|  | @ -71,29 +72,33 @@ class Index extends BaseSettings | |||
| 					break; | ||||
| 				case 'recovery': | ||||
| 					if ($has_secret) { | ||||
| 						DI::baseUrl()->redirect('settings/2fa/recovery?t=' . self::getFormSecurityToken('settings_2fa_password')); | ||||
| 						DI::baseUrl() | ||||
| 						  ->redirect('settings/2fa/recovery?t=' . self::getFormSecurityToken('settings_2fa_password')); | ||||
| 					} | ||||
| 					break; | ||||
| 				case 'app_specific': | ||||
| 					if ($has_secret) { | ||||
| 						DI::baseUrl()->redirect('settings/2fa/app_specific?t=' . self::getFormSecurityToken('settings_2fa_password')); | ||||
| 						DI::baseUrl() | ||||
| 						  ->redirect('settings/2fa/app_specific?t=' . self::getFormSecurityToken('settings_2fa_password')); | ||||
| 					} | ||||
| 					break; | ||||
| 				case 'trusted': | ||||
| 					if ($has_secret) { | ||||
| 						DI::baseUrl()->redirect('settings/2fa/trusted?t=' . self::getFormSecurityToken('settings_2fa_password')); | ||||
| 						DI::baseUrl() | ||||
| 						  ->redirect('settings/2fa/trusted?t=' . self::getFormSecurityToken('settings_2fa_password')); | ||||
| 					} | ||||
| 					break; | ||||
| 				case 'configure': | ||||
| 					if (!$verified) { | ||||
| 						DI::baseUrl()->redirect('settings/2fa/verify?t=' . self::getFormSecurityToken('settings_2fa_password')); | ||||
| 						DI::baseUrl() | ||||
| 						  ->redirect('settings/2fa/verify?t=' . self::getFormSecurityToken('settings_2fa_password')); | ||||
| 					} | ||||
| 					break; | ||||
| 			} | ||||
| 		} catch (FoundException $exception) { | ||||
| 			// Nothing to do here
 | ||||
| 		} catch (\Exception $e) { | ||||
| 			if (!($e instanceof FoundException)) { | ||||
| 				notice(DI::l10n()->t($e->getMessage())); | ||||
| 			} | ||||
| 			notice(DI::l10n()->t($e->getMessage())); | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue