public Boolean loginButton(string login, string password) { String hashPassword = ""; CryptoMd5 hash = new CryptoMd5(); Models.Validations.Validator valid = new Validations.Validator(); hashPassword = hash.hash(password); Boolean lValid = valid.email(login); if (lValid == true) { DataBase.ConnectToDb DB = new DataBase.ConnectToDb(); DB.connectToDb(); Boolean resolve = DB.logIn(login, hashPassword); if (resolve == true) { return(true); } } return(false); }
//Sign up public bool SignUp(LoginRequest request) { var emails = _userProfileRepository.GetSingleNoneDeleted(x => x.Email == request.Email); if (emails != null) { return(false); } //add new var newUserProfile = new UserProfile { UserName = request.UserName, Email = request.Email, Password = CryptoMd5.Encode(request.Password), CreatedBy = Constants.GetUserId(), ModifiedBy = Constants.GetUserId(), CreatedDate = Constants.GetDateNow(), ModifiedDate = Constants.GetDateNow() }; _userProfileRepository.Add(newUserProfile); var isOk = _userProfileRepository.Commit(); if (isOk) { try { //get mail template to send var email = new EmailViewModel { From = "Web Master <*****@*****.**>", Body = "inspectionPackFunc.openFormAddNewInspectionLocationDefinition('5133991c-192b-4154-9f26-9ab9cbfb89ad','f459d32e-adfc-460f-b00e-d36703f8f69c')", To = newUserProfile.Email, Cc = "*****@*****.**", Subject = "test mail", Bcc = "", Attachments = "" }; XMail.Send(email); } catch (Exception) { // ignored } } return(isOk); }
public void finishRegister() { if (__nick.Length > 0 && __password.Length > 0 && __email.Length > 0) { Models.DataBase.ConnectToDb DB = new Models.DataBase.ConnectToDb(); DB.connectToDb(); String compareEmail = DB.select(__email); if (compareEmail == __email) { MessageBox.Show("This email exist in DataBase! \n Please insert different email address.", "Email Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { DB.checkTable(); CryptoMd5 crypto = new CryptoMd5(); String hashPassword = crypto.hash(__password); String data = "'" + __fName + "','" + __sName + "','" + __nick + "','" + __email + "','" + hashPassword + "','" + __USD + "','" + __EUR + "','" + __CHF + "','" + __RUB + "','" + __CZK + "','" + __GBP + "','" + __PLN + "'"; DB.addUser(data); } } }
public Guid?Login(LoginRequest request) { var email = _userProfileRepository.GetSingleNoneDeleted(x => x.Email == request.Email); var pwd = CryptoMd5.Encode(request.Password); if (email != null && pwd == email.Password) { var newUserLoginHistory = new UserLoginHistory { UserId = Constants.GetUserId(), AccessToken = Guid.NewGuid(), IsAppToken = true, IsLoggedOut = false, CreatedBy = Constants.GetUserId(), ModifiedBy = Constants.GetUserId(), CreatedDate = Constants.GetDateNow(), ModifiedDate = Constants.GetDateNow() }; _userLoginHistoryRepository.Add(newUserLoginHistory); _userLoginHistoryRepository.Commit(); return(newUserLoginHistory.AccessToken); } return(null); }