public async Task <IActionResult> DisableTwoFactorAuthentication([FromBody] User_TwoFactorAuthentication_BindingModel collection) { HeaderValidator(collection); try { var model = _mapper.Map <User_DisableTwoFactorAuthentication_Schema>(collection); await _userService.DisableTwoFactorAuthentication(model); switch (model.StatusCode) { case 400: return(BadRequest(_stringLocalizer[SharedResource.TokenNotFound])); case 405: return(BadRequest(_stringLocalizer[SharedResource.DeviceIdNotFound])); case 410: return(BadRequest(_stringLocalizer[SharedResource.UserIsNotActive])); case 415: return(BadRequest(_stringLocalizer[SharedResource.WrongPassword])); case 200: return(Ok()); } } catch (Exception ex) { await _exceptionService.InsertAsync(ex, URL, IP); } return(InternalServerError()); }
public async Task <IActionResult> EnableTwoFactorAuthentication([FromBody] User_TwoFactorAuthentication_BindingModel collection) { HeaderValidator(collection); if (collection.Password.Length < 6) { return(BadRequest(_stringLocalizer["your password doesn't meet the legal length"])); } try { var model = _mapper.Map <User_EnableTwoFactorAuthentication_Schema>(collection); await _userService.EnableTwoFactorAuthentication(model); switch (model.StatusCode) { case 400: return(BadRequest(_stringLocalizer[SharedResource.AuthenticationFailed])); case 405: return(BadRequest(_stringLocalizer[SharedResource.DeviceIsNotActive])); case 410: return(BadRequest(_stringLocalizer[SharedResource.UserIsNotActive])); case 411: return(BadRequest(_stringLocalizer[SharedResource.RequestForVerificationCodeFirst])); case 412: return(BadRequest(_stringLocalizer[SharedResource.VerificationCodeHasBeenExpired])); case 413: return(BadRequest(_stringLocalizer[SharedResource.WrongVerificationCode])); case 200: return(Ok()); } } catch (Exception ex) { await _exceptionService.InsertAsync(ex, URL, IP); } return(InternalServerError()); }