public ResendOtpResponse ResendOtp(ResendOtpRequest request) { request.mobile_number = Common.GetStandardMobileNumber(request.mobile_number); ResendOtpResponse response = new ResendOtpResponse(); response.otp_details = new OTPDetailsDto(); Consumer consumer = null; try { using (UserDao userDao = new UserDao()) { consumer = userDao.FindByMobileNumber(request.mobile_number); } if (consumer == null) { MakeNouserResponse(response); return(response); } OTPServices.ResendOTP(response, consumer.PhoneNumber, consumer.ConsID, "C"); response.code = 0; response.has_resource = 1; response.message = MessagesSource.GetMessage("otp.resent"); response.otp_details.send_otp = 1; return(response); } catch (Exception ex) { response.MakeExceptionResponse(ex); return(response); } }
public ForgotPasswordResponse ForgotPassword(ForgotPasswordRequest request) { request.mobile_number = Common.GetStandardMobileNumber(request.mobile_number); ForgotPasswordResponse response = new ForgotPasswordResponse(); //string newPassword = TokenGenerator.GenerateResetPassword(); Consumer consumer = null; try { using (UserDao dao = new UserDao()) { consumer = dao.FindByMobileNumber(request.mobile_number); if (consumer == null) { MakeNouserResponse(response); return(response); } OTPServices.SendOTPForForgotPassword(response, request.mobile_number, consumer.ConsID, "C"); return(response); } } catch (Exception ex) { response.MakeExceptionResponse(ex); return(response); } }
public static ResendOtpResponse ResendOtp(DTOs.Gen.ResendOtpRequest request) { request.mobile_number = Common.GetStandardMobileNumber(request.mobile_number); ResendOtpResponse response = new ResendOtpResponse(); response.otp_details = new OTPDetailsDto(); AgentAdmin agentAdmin = null; try { using (AgentAdminDao adminDao = new AgentAdminDao()) { // agentBoss = GetAuthAgentBoss(request.user_id, request.auth_token, response); agentAdmin = adminDao.FindByMobileNumber(request.mobile_number); } if (agentAdmin == null) { MakeNouserResponse(response); return(response); } OTPServices.ResendOTP(response, agentAdmin.MobileNumber, agentAdmin.AgadmID, "A"); response.code = 0; response.has_resource = 1; response.message = MessagesSource.GetMessage("otp.resent"); response.otp_details.send_otp = 1; return(response); } catch (Exception ex) { response.MakeExceptionResponse(ex); return(response); } }
public static ResendOtpResponse ResendOtp(ResendOtpRequest request) { request.mobile_number = Common.GetStandardMobileNumber(request.mobile_number); ResendOtpResponse response = new ResendOtpResponse(); response.otp_details = new OTPDetailsDto(); SuperAdmin suerUser = null; try { using (SuperUserDao sUserDao = new SuperUserDao()) { suerUser = sUserDao.FindByMobileNumber(request.mobile_number); } if (suerUser == null) { MakeNouserResponse(response); return(response); } OTPServices.ResendOTP(response, suerUser.MobileNum, suerUser.SAdminID, "S"); response.code = 0; response.has_resource = 1; response.message = MessagesSource.GetMessage("otp.resent"); response.otp_details.send_otp = 1; return(response); } catch (Exception ex) { response.MakeExceptionResponse(ex); return(response); } }
public static ForgotPasswordResponse ForgotPassword(ForgotPasswordRequest request) { request.mobile_number = Common.GetStandardMobileNumber(request.mobile_number); ForgotPasswordResponse response = new ForgotPasswordResponse(); //string newPassword = TokenGenerator.GenerateResetPassword(); try { using (AgentAdminDao dao = new AgentAdminDao()) { AgentAdmin agentAdmin = dao.FindByMobileNumber(request.mobile_number); if (agentAdmin == null) { MakeNouserResponse(response); return(response); } OTPServices.SendOTPForForgotPassword(response, request.mobile_number, agentAdmin.AgadmID, "A"); return(response); } } catch (Exception ex) { response.MakeExceptionResponse(ex); return(response); } }
public static ResendOtpResponse ResendOtp(ResendOtpRequest request) { request.mobile_number = Common.GetStandardMobileNumber(request.mobile_number); ResendOtpResponse response = new ResendOtpResponse(); response.otp_details = new OTPDetailsDto(); AgentBoss agentBoss = null; try { using (AgentBossDao bossDao = new AgentBossDao()) { agentBoss = bossDao.FindByMobileNumber(request.mobile_number); } if (agentBoss == null) { MakeNouserResponse(response); return(response); } OTPServices.ResendOTP(response, agentBoss.MobileNumber, agentBoss.AbosID, "B"); response.code = 0; response.has_resource = 1; response.message = MessagesSource.GetMessage("otp.resent"); response.otp_details.send_otp = 1; return(response); } catch (Exception ex) { response.MakeExceptionResponse(ex); return(response); } }
public ResendOtpResponse ResendOtp(ResendOtpRequest request) { request.mobile_number = Common.GetStandardMobileNumber(request.mobile_number); ResendOtpResponse response = new ResendOtpResponse(); response.otp_details = new OTPDetailsDto(); Driver driver = null; try { using (DriverDao driverDao = new DriverDao()) { driver = driverDao.FindByMobileNumber(request.mobile_number); } if (driver == null) { MakeNoDriverResponse(response); return(response); } OTPServices.ResendOTP(response, driver.MobileNumber, driver.DrvrID, "D"); response.code = 0; response.has_resource = 1; response.message = MessagesSource.GetMessage("otp.resent"); response.otp_details.send_otp = 1; return(response); } catch (Exception ex) { response.MakeExceptionResponse(ex); return(response); } }
/// <summary> /// Register a new consumer. /// </summary> /// <param name="request">The DTO with requst form data parameters.</param> /// <returns>The response DTO with result of the operation.</returns> public RegisterResponse Register(RegisterRequest request) { request.mobile_number = Common.GetStandardMobileNumber(request.mobile_number); RegisterResponse responseDto = new RegisterResponse(); Consumer consumer = new Consumer(); //Get posted parameter values into the entity from the DTO UsersHelper.CopyToEntity(consumer, request); consumer.Password = TokenGenerator.GetHashedPassword(request.user_password, 49);//To fit into the password field of database table //Generate unique auth /access token for the user. consumer.AccToken = TokenGenerator.GenerateToken(request.user_name, request.user_password, request.mobile_number); consumer.CreatedDate = DateTime.Now; consumer.UpdatedDate = consumer.CreatedDate; consumer.StatusID = 1; consumer.ConsActivated = true; try { using (UserDao dao = new UserDao()) { // Check if the mobile number is registered if (dao.CheckPhoneExists(request.mobile_number)) { responseDto.code = 1; responseDto.has_resource = 0; responseDto.message = MessagesSource.GetMessage("cons.reg.dupl"); } else { consumer = dao.Insert(consumer); // save the entity. UsersHelper.CopyFromEntity(responseDto, consumer); //Copy to the response DTO string otp = OTPServices.GenerateAndSendOTP(request.mobile_number); if (OTPServices.SaveOTP(otp, consumer.ConsID, "C")) { responseDto.new_user.send_otp = 1; // state that OTP has been sent. } responseDto.code = 0; // Result OK. responseDto.has_resource = 1; responseDto.message = MessagesSource.GetMessage("cons.reg.ok"); } } } catch (Exception ex) { responseDto.MakeExceptionResponse(ex); } return(responseDto); }
public static ResponseDto CheckOTP(CheckOtpRequest request) { request.mobile_number = Common.GetStandardMobileNumber(request.mobile_number); ResponseDto response = new ResponseDto(); AgentBoss agentBoss = null; response.has_resource = 0; try { using (AgentBossDao dao = new AgentBossDao()) { agentBoss = dao.FindByMobileNumber(request.mobile_number); //agentBoss = GetAuthAgentBoss(request.user_id, request.auth_token, response); //agentBoss = GetAuthAgentBossNotAuthToken(request.user_id, response); if (agentBoss == null) { MakeNouserResponse(response); return(response); } bool otpValid = OTPServices.ValidateOTP(agentBoss.AbosID, request.otp_code); OTPServices.RemoveOTP(agentBoss.AbosID, request.otp_code);// Either way remove this otp if it exists. if (otpValid) { agentBoss.StatusId = true; dao.Update(agentBoss); response.code = 0; response.message = MessagesSource.GetMessage("otp.valid"); response.has_resource = 1; return(response); } response.code = 1; response.message = MessagesSource.GetMessage("otp.not.valid"); return(response); } } catch (Exception ex) { response.MakeExceptionResponse(ex); } return(response); }
//public ForgotPasswordResponse ForgotPassword(ForgotPasswordRequest request) //{ // ForgotPasswordResponse response = new ForgotPasswordResponse(); // string newPassword = TokenGenerator.GenerateResetPassword(); // Driver drv = null; // try // { // using (DriverDao dao = new DriverDao()) // { // drv = dao.FindByMobileNumber(request.mobile_number); // drv.Password = TokenGenerator.GetHashedPassword(newPassword, 49); // dao.Update(drv); // OTPServices.SendPasswordMessage(drv.MobileNumber, newPassword); // response.code = 0; // response.has_resource = 1; // response.reset_password = new ResetPasswordDto(); // response.reset_password.password_otp_sent = 1; // response.reset_password.password_reset = 1; // response.message = MessagesSource.GetMessage("passwd.reset"); // } // } // catch (Exception ex) // { // response.MakeExceptionResponse(ex); // } // return response; //} public ResponseDto CheckOTP(CheckOtpRequest request) { request.mobile_number = Common.GetStandardMobileNumber(request.mobile_number); ResponseDto response = new ResponseDto(); Driver driver = null; response.has_resource = 0; try { using (DriverDao dao = new DriverDao()) { driver = dao.FindByMobileNumber(request.mobile_number); if (driver == null) { MakeNoDriverResponse(response); return(response); } bool otpValid = OTPServices.ValidateOTP(driver.DrvrID, request.otp_code); OTPServices.RemoveOTP(driver.DrvrID, request.otp_code);// Either way remove this otp if it exists. if (otpValid) { driver.StatusId = true; dao.Update(driver); response.code = 0; response.message = MessagesSource.GetMessage("otp.valid"); response.has_resource = 1; return(response); } response.code = 1; response.message = MessagesSource.GetMessage("otp.not.valid"); return(response); } } catch (Exception ex) { response.MakeExceptionResponse(ex); } return(response); }
public ResponseDto ActivateUser(ActivateUserRequest request) { ResponseDto response = new ResponseDto(); Consumer consumer = null; try { using (UserDao userDao = new UserDao()) { consumer = GetAuthUser(userDao, request.user_id, request.auth_token); if (consumer == null) { MakeNouserResponse(response); return(response); } if (consumer.ConsActivated) { response.code = 0; response.has_resource = 0; response.message = MessagesSource.GetMessage("user.active"); return(response); } bool validOtp = OTPServices.ValidateOTP(request.user_id, request.otp_code); if (validOtp) { consumer.ConsActivated = true; userDao.Update(consumer); response.code = 0; response.has_resource = 0; response.message = MessagesSource.GetMessage("user.activated"); } return(response); } } catch (Exception ex) { response.MakeExceptionResponse(ex); return(response); } }
public static ResponseDto CheckOtp(CheckOtpRequest request) { request.mobile_number = Common.GetStandardMobileNumber(request.mobile_number); ResponseDto response = new ResponseDto(); SuperAdmin superuser = null; response.has_resource = 0; try { using (SuperUserDao dao = new SuperUserDao()) { superuser = GetAuthUserbyMobileNumber(request.mobile_number); if (superuser == null) { MakeNouserResponse(response); return(response); } bool otpValid = OTPServices.ValidateOTP(superuser.SAdminID, request.otp_code); OTPServices.RemoveOTP(superuser.SAdminID, request.otp_code);// Either way remove this otp if it exists. if (otpValid) { dao.Update(superuser); response.code = 0; response.message = MessagesSource.GetMessage("otp.valid"); return(response); } response.code = 1; response.message = MessagesSource.GetMessage("otp.not.valid"); return(response); } } catch (Exception ex) { response.MakeExceptionResponse(ex); return(response); } }