public static LoginResponse Login(LoginRequest request) { request.mobile_number = Common.GetStandardMobileNumber(request.mobile_number); LoginResponse response = new LoginResponse(); SuperAdmin superuser = null; string hashPassword = TokenGenerator.GetHashedPassword(request.password, 49); try { using (SuperUserDao dao = new SuperUserDao()) { superuser = dao.FindByMobileNumber(request.mobile_number); if (superuser == null) { MakeNouserResponse(response); return(response); } if (hashPassword == superuser.Password) { response.code = 1; response.has_resource = 0; //admin. = request.app_id; superuser.AppToken = request.push_token; superuser.AppID = request.app_id; superuser.LastLogin = DateTime.Now; string authToken = TokenGenerator.GenerateToken(superuser.FullName, superuser.Password, request.mobile_number); superuser.AccToken = authToken; dao.Update(superuser); response.code = 0; SuperUserLoginDto dto = new SuperUserLoginDto(); SuperUserHelper.CopyFromEntity(dto, superuser); SuperUserLoginDetailsDto dtoDetails = new SuperUserLoginDetailsDto(); SuperUserHelper.CopyFromEntity(dtoDetails, superuser); response.user_login = dto; response.super_user_details = dtoDetails; 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); }
public LoginResponse Login(LoginRequest request) { request.mobile_number = Common.GetStandardMobileNumber(request.mobile_number); LoginResponse response = new LoginResponse(); Consumer consumer = null; string hashPassword = TokenGenerator.GetHashedPassword(request.user_password, 49); try { using (UserDao dao = new UserDao()) { consumer = dao.FindByMobileNumber(request.mobile_number); if (consumer == null) { MakeNouserResponse(response); return(response); } if (hashPassword == consumer.Password) { response.code = 1; response.has_resource = 0; if (consumer.ConsBlocked) { response.message = MessagesSource.GetMessage("user.blocked"); return(response); } if (!consumer.ConsActivated) { response.message = MessagesSource.GetMessage("user.not.active"); return(response); } consumer.AppID = request.app_id; consumer.AppToken = request.push_token; consumer.LastLogin = DateTime.Now; consumer.AccToken = TokenGenerator.GenerateToken(consumer.Name, consumer.Password, consumer.PhoneNumber); dao.Update(consumer); response.code = 0; UsersHelper.CopyFromEntity(response, consumer); response.has_resource = 1; if (response.user_login.allow_login == 1) { response.code = 0; response.message = MessagesSource.GetMessage("login.ok"); return(response); } } } } catch (Exception ex) { response.MakeExceptionResponse(ex); } return(response); }
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); }
public LoginResponse Login(LoginRequest request) { request.mobile_number = Common.GetStandardMobileNumber(request.mobile_number); LoginResponse response = new LoginResponse(); Driver driver = null; string hashPassword = TokenGenerator.GetHashedPassword(request.password, 49); try { using (DriverDao dao = new DriverDao()) { //driver = dao.FindByMobileNumber(request.mobile_number); driver = dao.FindByMobileNumberAndPassword(request.mobile_number, hashPassword); if (driver == null) { MakeNoDriverResponse(response); return(response); } driver.AppID = request.app_id; driver.AppToken = request.push_token; driver.LastLogin = DateTime.Now; driver.AccToken = TokenGenerator.GenerateToken(driver.DriverName, driver.Password, driver.MobileNumber); dao.Update(driver); response.code = 0; response.user_login = new UserLoginDto(); response.driver_details = new DriverDetails(); response.reminder_details = new ReminderDetailsDto(); var reminder = dao.GetRemindersForDriver(); response.has_reminder = (reminder == null ? 0 : 1); //if (reminder == null) //{ // reminder = new Reminder(); //} DriverHelper.CopyFromEntity(response, driver, reminder); response.has_resource = 1; response.message = MessagesSource.GetMessage("login.ok"); return(response); } } catch (Exception ex) { response.MakeExceptionResponse(ex); } return(response); }