public LoginResultDTO Relogin(string email) { if (string.IsNullOrWhiteSpace(email)) { return(null); } var m_accountRepository = UnitOfWork.Repository <DB_TB_ACCOUNTS>(); var m_account = m_accountRepository.Get(a => a.ACC_EMAIL == email); ContextDTO context = new ContextDTO() { Id = m_account.ACC_SYS_ID, Email = m_account.ACC_EMAIL, FirstName = m_account.ACC_FIRSTNAME, LastName = m_account.ACC_LASTNAME }; m_account.ACC_TOKEN = EncryptDecryptUtility.Encrypt(XmlUtility.Serialize(context), true); m_accountRepository.Update(m_account); UnitOfWork.Commit(); return(new LoginResultDTO() { Email = m_account.ACC_EMAIL, Id = m_account.ACC_SYS_ID, Token = m_account.ACC_TOKEN, FirstName = m_account.ACC_FIRSTNAME, LastName = m_account.ACC_LASTNAME }); }
//public Object UpdateDesign(int aid) //{ // var returnObj = (new // { // success = false, // error = "Invalid Request" // }); // try // { // Boolean flag = false; // var secUserForSession = SessionManager.CurrentUser; // if (secUserForSession.ApproverDesignations.Count > 0 && secUserForSession.IsContributor) // { // var desig = secUserForSession.ApproverDesignations.Where(p => p.ApproverID == aid).FirstOrDefault(); // if (desig != null) // { // var rolesList = new List<String>(); // var permList = new List<String>(); // permList = DataService.GetRolePermissionById(aid, out rolesList); // PermissionManager.HandlePermissions(permList); // secUserForSession.Roles = rolesList; // flag = true; // } // } // if (flag) // { // SessionManager.CurrentUser = secUserForSession; // return (new // { // success = true, // error = "" // }); // } // else // { // return returnObj; // } // } // catch (Exception ex) // { // return returnObj; // } //} public Object sendEmail(string emailAddress) { if (PUCIT.AIMRL.TLS.UI.Common.SessionManager.LogsInAsOtherUser == true) { return(new { success = false, error = "You Are Not Allowed" }); } try { var userObj = DataService.GetUserByEmail(emailAddress); if (userObj != null) { string token = ""; token = HttpUtility.UrlEncode(EncryptDecryptUtility.Encrypt(emailAddress)); String url = PUCIT.AIMRL.TLS.UI.Common.Resources.GetCompletePath("~/Login/ResetPassword1"); url = String.Format("{0}?rt={1}", url, token); String subject = "Reset Password"; String msg = String.Format("Click the link below to reset your password \n {0}", url); EmailHandler.SendEmail(emailAddress, subject, msg); } else { return(new { success = false, error = "email not correct" }); } return(new { data = new { Id = emailAddress }, success = true, error = "" }); } catch (Exception ex) { return(new { success = false, error = "email not correct" }); } }
public LoginResultDTO Login(LoginDTO dto) { var m_accountRepository = UnitOfWork.Repository <DB_TB_ACCOUNTS>(); if (!IsExistAccount(dto.Email)) { base.AddError("Account is not existed !"); return(null); } var m_account = m_accountRepository.Get(a => a.ACC_EMAIL == dto.Email && a.ACC_PASSWORD == dto.Password && a.ACC_IS_ACTIVED); if (m_account == null) { base.AddError("Password incorrect!"); return(null); } //if (string.IsNullOrEmpty(m_account.ACC_TOKEN)) //{ // // ma hoa thong tin dang nhap // ContextDTO context = new ContextDTO() { // Id=m_account.ACC_SYS_ID, // Email=m_account.ACC_EMAIL, // FirstName=m_account.ACC_FIRSTNAME, // LastName=m_account.ACC_LASTNAME // }; // m_account.ACC_TOKEN =EncryptDecryptUtility.Encrypt(XmlUtility.Serialize(context),true); //} ContextDTO context = new ContextDTO() { Id = m_account.ACC_SYS_ID, Email = m_account.ACC_EMAIL, FirstName = m_account.ACC_FIRSTNAME, LastName = m_account.ACC_LASTNAME }; m_account.ACC_RESGISTRANTION_ID = dto.DeviceKey; m_account.ACC_LASTLOGIN_DATE = DateTime.Now; if (string.IsNullOrEmpty(m_account.ACC_TOKEN)) { m_account.ACC_TOKEN = EncryptDecryptUtility.Encrypt(XmlUtility.Serialize(context), true); } m_accountRepository.Update(m_account); UnitOfWork.Commit(); return(new LoginResultDTO() { Email = m_account.ACC_EMAIL, Id = m_account.ACC_SYS_ID, Token = m_account.ACC_TOKEN, FirstName = m_account.ACC_FIRSTNAME, LastName = m_account.ACC_LASTNAME });// SingletonAutoMapper._Instance.MapperConfiguration.CreateMapper().Map<LoginResultDTO>(m_account); }