public async Task <ActivateAccountResponse> ActivateAccount(ActivateAccountRequest request) { var response = new ActivateAccountResponse(); using (var uow = _uowFactory.GetUnitOfWork()) { var userToken = await uow.UserRepo.GetUserTokenByGuid(new Infrastructure.Repositories.UserRepo.Models.GetUserTokenByGuidRequest() { Guid = new Guid(request.Token) }); if (userToken == null) { response.Notifications.AddError("Token does not exist"); return(response); } if (userToken.Type_Id != TokenTypeEnum.AccountActivation) { response.Notifications.AddError("Invalid token provided"); return(response); } if (userToken.Processed) { response.Notifications.AddError($"This account has already been activated"); return(response); } await uow.UserRepo.ActivateAccount(new Infrastructure.Repositories.UserRepo.Models.ActivateAccountRequest() { User_Id = userToken.User_Id, Updated_By = ApplicationConstants.SystemUserId }); uow.Commit(); } response.Notifications.Add($"Your account has been activated", NotificationTypeEnum.Success); return(response); }
public ActivateAccountResponse ActivateAccount(ActivateAccountRequest request) { var response = new ActivateAccountResponse(); try { if (WebSecurity.ConfirmAccount(request.ActivateAccountToken)) { response.Success = true; } else { response.Message = Resources.Account.InvalidToken; } } catch (Exception ex) { this.exceptionHandler.HandleException(ex); response.Message = Resources.Common.InternalServerError; } return(response); }
public ActivateAccountResponse ActivateAccount(ActivateAccountRequest request) { var response = new ActivateAccountResponse(); try { if (WebSecurity.ConfirmAccount(request.ActivateAccountToken)) { response.Status = StatusCode.OK; } else { response.Status = StatusCode.Unauthorized; } } catch (Exception ex) { response.Status = StatusCode.InternalServerError; this.exceptionHandler.HandleException(ex); } return response; }
public ResponseBase Any(ActivateAccount request) { _logger.Log(EErrorType.Info, " ****** Call start: ActivateAccount"); ActivateAccountResponse response = new ActivateAccountResponse(); try { GetUserAccountInfoParams accParams = new GetUserAccountInfoParams(); accParams.Email = request.Email; GetUserAccountInfoResult accResult = _dal.GetUserAccountInfo(accParams); if (accResult != null) { if (accResult.ActivationCode == request.ActivationCode) { CreateUpdateUserAccountParams updateParams = new CreateUpdateUserAccountParams(); updateParams.AccountKey = accResult.AccountKey; updateParams.State = "active"; // TODO: need to change to consts _dal.UpdateUserAccount(updateParams); response.Success = true; } else { response.Success = false; response.Errors.Add(new Error() { Code = EErrorCodes.UserAccountNotValidated, Type = EErrorType.Error, Message = "Invalid activation code provided - account was not activated" } ); } } else { response.Success = false; response.Errors.Add(new Error() { Code = EErrorCodes.UserAccountNotFound, Type = EErrorType.Error, Message = "User account was not found." } ); } } catch (Exception ex) { _logger.Log(ex); response.Success = false; response.Errors.Add(new Error() { Code = EErrorCodes.GeneralError, Type = EErrorType.Error, Message = string.Format("Unexpected error: {0}", ex.Message) }); } _logger.Log(EErrorType.Info, " ****** Call end: ActivateAccount"); return(response); }