Beispiel #1
0
        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);
            }
        }
Beispiel #2
0
        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);
            }
        }
Beispiel #3
0
        public static LoginResponse Login(LoginRequest request)
        {
            request.mobile_number = Common.GetStandardMobileNumber(request.mobile_number);
            LoginResponse response     = new LoginResponse();
            AgentAdmin    admin        = null;
            string        hashPassword = TokenGenerator.GetHashedPassword(request.password, 49);

            try
            {
                using (AgentAdminDao dao = new AgentAdminDao())
                {
                    admin = dao.FindByMobileNumber(request.mobile_number);
                    if (admin == null)
                    {
                        MakeNouserResponse(response);
                        return(response);
                    }
                    if (hashPassword == admin.Password)
                    {
                        response.code         = 1;
                        response.has_resource = 0;
                        //admin. = request.app_id;
                        admin.AppToken  = request.push_token;
                        admin.AppID     = request.app_id;
                        admin.LastLogin = DateTime.Now;
                        string authToken = TokenGenerator.GenerateToken(admin.AgentAdminName, admin.Password, request.mobile_number);
                        admin.AccToken = authToken;
                        dao.Update(admin);
                        response.code = 0;
                        UserLoginDto dto = new UserLoginDto();
                        AgentHelper.CopyFromEntity(dto, admin);
                        response.user_login   = dto;
                        response.has_resource = 1;
                        response.code         = 0;
                        response.message      = MessagesSource.GetMessage("login.ok");
                        return(response);
                    }
                    else
                    {
                        response.code         = 1;
                        response.has_resource = 0;
                        response.message      = MessagesSource.GetMessage("login.fail");
                    }
                }
            }
            catch (Exception ex)
            {
                response.MakeExceptionResponse(ex);
            }
            return(response);
        }
Beispiel #4
0
        public static ResponseDto CheckOTP(CheckOtpRequest request)
        {
            request.mobile_number = Common.GetStandardMobileNumber(request.mobile_number);
            ResponseDto response   = new ResponseDto();
            AgentAdmin  agentAdmin = null;

            response.has_resource = 0;
            try
            {
                using (AgentAdminDao dao = new AgentAdminDao())
                {
                    agentAdmin = dao.FindByMobileNumber(request.mobile_number);
                    //agentBoss = GetAuthAgentBoss(request.user_id, request.auth_token, response);
                    //agentBoss = GetAuthAgentBossNotAuthToken(request.user_id, response);
                    if (agentAdmin == null)
                    {
                        MakeNouserResponse(response);
                        return(response);
                    }

                    bool otpValid = OTPServices.ValidateOTP(agentAdmin.AgadmID, request.otp_code);
                    OTPServices.RemoveOTP(agentAdmin.AgadmID, request.otp_code);// Either way remove this otp if it exists.
                    if (otpValid)
                    {
                        agentAdmin.StatusId = true;
                        dao.Update(agentAdmin);
                        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);
        }
Beispiel #5
0
        public static ResponseDto ResetPassword(ResetPasswordRequest request)
        {
            request.mobile_number = Common.GetStandardMobileNumber(request.mobile_number);
            ResponseDto response            = new ResponseDto();
            AgentAdmin  agentAdmin          = null;
            string      newPasswordHash     = TokenGenerator.GetHashedPassword(request.new_password, 49);
            string      confirmPasswordHash = TokenGenerator.GetHashedPassword(request.confirm_password, 49);

            try
            {
                using (AgentAdminDao dao = new AgentAdminDao())
                {
                    agentAdmin = dao.FindByMobileNumber(request.mobile_number);
                    if (agentAdmin == null)
                    {
                        MakeNouserResponse(response);
                        return(response);
                    }
                    if (newPasswordHash == confirmPasswordHash)
                    {
                        agentAdmin.Password = TokenGenerator.GetHashedPassword(request.new_password, 49);
                        dao.Update(agentAdmin);
                        response.code         = 0;
                        response.has_resource = 1;
                        response.message      = MessagesSource.GetMessage("passwd.reset");
                        return(response);
                    }
                }
                response.code         = 1;
                response.has_resource = 0;
                response.message      = MessagesSource.GetMessage("exception");
                return(response);
            }
            catch (Exception ex)
            {
                response.MakeExceptionResponse(ex);
                return(response);
            }
        }