public ActionResult ChangePassword(TUser tuser, string oldPassword, string keyPassword) { try { byte[] hashedValueOfKeyPassword = sha512.ComputeHash(Encoding.UTF8.GetBytes(keyPassword)); byte[] hashedValueOfPassword = sha512.ComputeHash(Encoding.UTF8.GetBytes(tuser.Password)); byte[] hashedValueOfConfirmPassword = sha512.ComputeHash(Encoding.UTF8.GetBytes(tuser.ConfirmPassword)); string hexOfValuePassword = BitConverter.ToString(hashedValueOfPassword); string hexOfValueConfirmPassword = BitConverter.ToString(hashedValueOfConfirmPassword); string hexOfValueKeyPassword = BitConverter.ToString(hashedValueOfKeyPassword); //keyPassword if (oldPassword == hexOfValueKeyPassword) { if (ModelState.IsValid) { tuser.Password = hexOfValuePassword; tuser.ConfirmPassword = hexOfValueConfirmPassword; objBs.tuserBs.Update(tuser); return RedirectToAction("ChangePassword", "Login", new { sms = "Change password Successfully , Please Sign out and then login again !" }); } else { return RedirectToAction("ChangePassword", "Login", new { sms = "Failed! " + "ModelState not valid !" }); } } else { return RedirectToAction("ChangePassword", "Login", new { sms = "Failed! " + "Old password incorrected !" }); } } catch (Exception ex) { return RedirectToAction("ChangePassword", "Login", new { sms = "Failed! " + "Change password operation failed " + ex.Message }); } }
public static void AddUser(string name, DateTime birthDate, decimal wage, double height, double weight) { TUser user = new TUser(); user.BirthDate = birthDate; user.Height = height; user.Name = name; user.Wage = wage; user.Weight = weight; user.SaveOrUpdate(); }
protected virtual Task <ActionResult> InvokeCancelChangeEmail( TAccountsController controller, TUser account, Func <Fakes, User> getCurrentUser, TAccountViewModel model = null) { // Arrange controller.SetCurrentUser(getCurrentUser(Fakes)); var userService = GetMock <IUserService>(); userService.Setup(u => u.FindByUsername(account.Username, false)) .Returns(account as User); userService.Setup(u => u.CancelChangeEmailAddress(account)) .Returns(Task.CompletedTask) .Verifiable(); model = model ?? Activator.CreateInstance <TAccountViewModel>(); model.AccountName = account.Username; // Act return(controller.CancelChangeEmail(model)); }
public async void Connect() { client = await ClientFactory.BuildClient( new FactorySettings { Id = AppSettings.API_ID, Hash = AppSettings.API_HASH, StoreProvider = new TelegramClient.Core.Sessions.FileSessionStoreProvider("session"), ServerAddress = AppSettings.IP, ServerPort = AppSettings.PORT }); await client.ConnectService.ConnectAsync(); client.UpdatesService.RecieveUpdates += CheckUpdates; var contacts = await client.ContactsService.GetContactsAsync(); _user = (contacts as TContacts).Users.Items.OfType <TUser>().FirstOrDefault(x => x.Username == "BValitov"); //await client.MessagesService.SendMessageAsync(new TInputPeerUser() { UserId = user.Id}, "ты не пидор"); }
public ActionResult Create([Bind(Include = "user_code,user_pwd,eff_date,exp_date,member_seq,role_name")] TUser tUser) { if (ModelState.IsValid) { TUser result = db.TUsers.Find(tUser.user_code); if (result == null) { tUser.upd_date = DateTime.Now; tUser.user_pwd = FormsAuthentication.HashPasswordForStoringInConfigFile(tUser.user_pwd, "SHA1"); db.TUsers.Add(tUser); db.SaveChanges(); var identity = (HttpContext.User as RegisterLions.MyPrincipal).Identity as RegisterLions.MyIdentity; // Write log to table TransactionLog //ProjLib projlib = new ProjLib(); ProjLib.writeTransactionLog(identity.User.member_seq, "CreateTUser", identity.User.club_id); return(RedirectToAction("Index")); } else { ViewBag.errorMessage = "รหัสผู้ใช้ซ้ำ"; } } List <SelectListItem> lstRoleName = new List <SelectListItem>(); lstRoleName.Add(new SelectListItem() { Text = "ผู้ดูแลระบบ", Value = "Admin" }); lstRoleName.Add(new SelectListItem() { Text = "ผู้ใช้งาน", Value = "User" }); ViewBag.role_name = new SelectList(lstRoleName, "Value", "Text", tUser.role_name); ViewBag.member_seq = new SelectList(db.Members.OrderBy(x => x.first_name_eng).ThenBy(x => x.last_name_eng), "member_seq", "full_name_eng", tUser.member_seq); ViewBag.club_id = new SelectList(db.Clubs.OrderBy(x => x.club_name_thai), "club_id", "club_name_thai"); return(View(tUser)); }
public async Task <ApiRequestResult> SignUp([FromBody] SignUpParam param) { var userId = Guid.NewGuid(); var asampleUser = new ASampleUser { Id = userId.ToString(), UserName = param.UserName, Email = param.Email, PhoneNumber = param.PhoneNumber, }; var hashedNewPassword = _userManager.PasswordHasher.HashPassword(asampleUser, param.Password); var user = new TUser { Id = userId, UserName = param.UserName, Email = param.Email, PhoneNumber = param.PhoneNumber, Password = hashedNewPassword, //OrgId = param.OrgId, //LoginName = param.LoginName, }; await _userRepository.AddAsync(user); //var asampleUser = new ASampleUser //{ // UserName = param.UserName, // Email = param.Email, // PhoneNumber = param.PhoneNumber, //}; var result = await _userManager.CreateAsync(asampleUser, param.Password); if (result.Succeeded) { return(ApiRequestResult.Success("注册成功")); } return(ApiRequestResult.Error(result.Errors.FirstOrDefault().Description)); }
public Task <ResultWrapper <GetCustomerOrdersOutput> > Handle(GetCustomerOrdersQuery request, CancellationToken cancellationToken) { ResultWrapper <GetCustomerOrdersOutput> result = new ResultWrapper <GetCustomerOrdersOutput>(); TUser tUser = _dbContext.TUser.FirstOrDefault(x => x.FireBaseId == request.firebaseId); if (tUser == null) { result.Status = false; result.Message = "cannot find customer!"; return(Task.FromResult(result)); } var list = _dbContext.TOrder .Include(x => x.TSupplier) .Where(x => x.TUserId == tUser.Id) .Where(x => x.Submited) .Select(tData => new GetCustomerOrdersOutput.OrderItem() { Id = tData.Id, Title = tData.Title, TotalPayablePrice = tData.TotalPayablePrice, Restaurant = tData.TSupplier.RestaurantName, Date = tData.Date }) .ToList(); result.Status = true; result.Result = new GetCustomerOrdersOutput() { list = list }; return(Task.FromResult(result)); }
public JsonResult DeleteConfirmed(string id) { string[] tid = id.Split(','); JsonResult json = new JsonResult(); json.Data = true; for (int i = 0; i < tid.Length; i++) { try { string aa = tid[i]; int idi = Convert.ToInt32(aa); TUser tuser = db.TUser.Single(t => t.ID == idi); db.TUser.DeleteObject(tuser); db.SaveChanges(); } catch (Exception ee) { //json.Data = ee.Message; } } return(json); }
protected virtual ActionResult InvokeConfirmationRequiredPost( TAccountsController controller, TUser account, string confirmationUrl = null) { // Arrange var userService = GetMock <IUserService>(); userService.Setup(u => u.FindByUsername(account.Username)) .Returns(account as User); GetMock <IMessageService>() .Setup(m => m.SendNewAccountEmail( It.IsAny <MailAddress>(), string.IsNullOrEmpty(confirmationUrl) ? It.IsAny <string>() : confirmationUrl)) .Callback <MailAddress, string>((actualMailAddress, actualConfirmationUrl) => { Assert.Equal(account.UnconfirmedEmailAddress, actualMailAddress.Address); }) .Verifiable(); // Act return(controller.ConfirmationRequiredPost(account.Username)); }
public ActionResult <Result> PublishAppend([FromRoute] string articleId, [FromBody] TArticleLang article) { //获取用户信息 string user_id = Token.GetUserId(HttpContext.Request.Headers["Authorization"].ToString().Substring(7)); TUser user = userServer.Retrieve(new TUser() { UserId = user_id }); if (user.Super != 1) { throw new ResultException("无权操作"); } if (!typeServer.IsArticleType(article.TypeId)) { throw new ResultException("文章类型错误"); } articleServer.VerifyPublish(article); TType type = typeServer.Retrieve(new TType() { TypeId = article.TypeId }); if (articleServer.RetrieveByLang(articleId, type.LangId.Value) != null) { throw new ResultException("已存在对应语言的文章"); } article.ArticleId = articleId; articleServer.PublishByLang(article, user); return(new Result(200, "发布成功")); }
public SecurityContext Init(Func <IIdentity> identityGetter, Subdomain subdomain) { _identityGetter = identityGetter; _isAuthenticated = TryGet(x => x.IsAuthenticated, false); var username = TryCast(x => x.Name, string.Empty); if (_isAuthenticated && !string.IsNullOrEmpty(username)) { if (subdomain == Subdomain.Admin) { var user = TUser.FindByUsername(username); if (user != null) { _user = new UserSecurity(user, subdomain); } } else { var model = TClient.FindByUsername(username); if (model != null) { _user = new UserSecurity(model); } } } else { _user = null; } if (_user == null) { _isAuthenticated = false; } return(this); }
public void ToServerEncryption() { var user = new TUser { AccessHash = 11111, Id = 1 }; var input = Serializer.Serialize(user); var output = PooledByteBufferAllocator.Default.Buffer(); MtProtoHelper.ToServerEncrypt(input, _session, 0, SeqNumber, output); var dencryptedData = MtProtoHelper.FromClientDecrypt(output, _session, out var authKeyId, out var serverSalt, out var sessionId, out var messageId, out var seqNumber); input.ResetReaderIndex(); Assert.Equal(input.ToArray(input.ReadableBytes), dencryptedData.ToArray(dencryptedData.ReadableBytes)); Assert.Equal(_session.AuthKey.Id, authKeyId); Assert.Equal(_session.ServerSalt, serverSalt); Assert.Equal(_session.SessionId, sessionId); Assert.Equal(_seqNumber - 1, seqNumber); }
protected void btnStartAndEnterTopic_Click(object sender, EventArgs e) { List <TCourse> listTCourse = (List <TCourse>)Session["currentCourses"]; TCourse tCourse = null; string tCourseId = lbCurrentCourses.SelectedValue; for (int count = 0; count < listTCourse.Count; count++) { tCourse = listTCourse[count]; if (tCourse.id == tCourseId) { break; } } TUser tUser = (TUser)Session["user"]; //Insert in DATABASE TTopic tTopic = DbControl.getInstance().createTopic(tUser, tCourse, tbTopicTitle.Text); Application["updateAvaiable_" + tTopic.id.ToString()] = 0; Session["updateAvaiable"] = 0; DbControl.getInstance().enterTopic(tUser, tTopic); Response.Redirect("topic.aspx"); }
public async Task Authenticate() { var sentCode = await ClientApi.AuthService.SendCodeAsync(PhoneNumber).ConfigureAwait(false); TUser user = null; try { user = await ClientApi.AuthService.SignInAsync(PhoneNumber, sentCode, PhoneCode).ConfigureAwait(false); } catch (CloudPasswordNeededException) { //TODO: Set the cloud password here const string Password = ""; throw new NotSupportedException(); // user = await ClientApi.AuthService.CheckCloudPasswordAsync(Password).ConfigureAwait(false); } catch (PhoneCodeInvalidException) { } Assert.NotNull(user); }
void OnRegister(NetConnection <NetSession> sender, UserRegisterRequest request) { sender.Session.Response.userRegister = new UserRegisterResponse(); TUser user = DBService.Instance.Entities.Users.Where(u => u.Username == request.User).FirstOrDefault(); if (user != null) { sender.Session.Response.userRegister.Result = Result.Failed; sender.Session.Response.userRegister.Errormsg = "用户已存在"; } else { DBService.Instance.Entities.Users.Add(new TUser() { Player = new TPlayer(), Username = request.User, Password = request.Passward }); DBService.Instance.Entities.SaveChanges(); sender.Session.Response.userRegister.Result = Result.Success; sender.Session.Response.userRegister.Errormsg = "None"; } sender.SendResponse(); }
public void UpdateUser(TUser user) { }
public void AddUser(TUser user) { //.. }
public void RevokeRefreshToken(TUser user) { user.RefreshToken = null; //db save }
public SeedUser(TUser user, bool syncRoles, params string[] roles) { User = user; SyncRoles = syncRoles; Roles = roles; }
public ActionResult Create([Bind(Include = "member_id,first_name,last_name,gender,member_address_eng,post_code,email,cell_phone,birth_year,occupation,Join_Date,club_id,member_seq,membership_type,first_name_eng,last_name_eng,member_address_thai,sponsor_name,charter_flag,member_sts,line_id")] Member member, HttpPostedFileBase image) //public ActionResult Create([Bind(Include = "member_id,first_name,last_name,gender,member_address_eng,email,cell_phone,birth_year,occupation,Join_Date,club_id,member_seq,membership_type,first_name_eng,last_name_eng,member_address_thai")] Member member) { var identity = (HttpContext.User as RegisterLions.MyPrincipal).Identity as RegisterLions.MyIdentity; if (ModelState.IsValid) { //Member result = db.Members.Find(member.member_id); var result = (from m in db.Members where m.member_id == member.member_id select m ); if (result.Count() == 0) { if (image != null && image.ContentLength > 0) { using (var reader = new System.IO.BinaryReader(image.InputStream)) { member.image = reader.ReadBytes(image.ContentLength); } } member.upd_date = DateTime.Now; db.Members.Add(member); string tMovement = Request.Form["movement"]; string tMoveDate = Request.Form["movedate"]; MemberMovement memberMovement = new MemberMovement(); if (tMovement != "1" && Convert.ToDateTime(tMoveDate) != memberMovement.hist_date) { MemberMovement memberMovement1 = new MemberMovement(); memberMovement1.member_seq = member.member_seq; memberMovement1.hist_date = member.join_date; memberMovement1.club_id = null; memberMovement1.move_sts = 1; db.MemberMovements.Add(memberMovement1); } if (tMovement == "1") { memberMovement.hist_date = member.join_date; } else { memberMovement.hist_date = Convert.ToDateTime(tMoveDate); } memberMovement.member_seq = member.member_seq; memberMovement.club_id = member.club_id; memberMovement.move_sts = Int32.Parse(tMovement); db.MemberMovements.Add(memberMovement); //ProjLib projlib = new ProjLib(); var user_code = ProjLib.chkUserCode(member.first_name_eng, member.last_name_eng); TUser tuser = new TUser(); //tuser.user_code = member.first_name_eng.ToLower() + "." + member.last_name_eng.ToLower().Substring(0, 1); tuser.user_code = user_code; //tuser.user_pwd = FormsAuthentication.HashPasswordForStoringInConfigFile(member.first_name_eng.ToLower() + "." + member.last_name_eng.ToLower().Substring(0, 1) + "@123", "SHA1"); tuser.user_pwd = FormsAuthentication.HashPasswordForStoringInConfigFile(user_code + "@123", "SHA1"); tuser.role_name = "User"; tuser.member_seq = member.member_seq; tuser.upd_date = DateTime.Now; db.TUsers.Add(tuser); db.SaveChanges(); // Write log to table TransactionLog ProjLib.writeTransactionLog(identity.User.member_seq, "CreateMember", identity.User.club_id); return(RedirectToAction("Index")); } else { ViewBag.errorMessage = "รหัสสมาชิกซ้ำ"; } } ViewBag.club_id = new SelectList(db.Clubs.Where(x => x.district_id == identity.User.district_id).OrderBy(x => x.club_name_thai), "club_id", "club_name_thai", member.club_id); ViewBag.membership_type = new SelectList(db.MembershipTypes.OrderBy(x => x.membership_desc_thai), "membership_type", "membership_desc_thai", member.membership_type); ViewBag.movement = new SelectList(db.Movements.OrderBy(x => x.move_desc), "move_sts", "move_desc"); return(View(member)); }
//------------------------------------------------------------ public TLeaveApplicationViewModel() { iv_Leave = new TLeaveApplication(); iv_User = new TUser(); iv_Department = new TUserDepartment(); }
public bool Delete(TUser user) { return(controller.Delete(TransporterToModel(user))); }
public TLeaveApplicationViewModel(TLeaveApplication p, TUser u) { iv_Leave = p; iv_User = u; }
public IActionResult UserEdit(TUser user, int id, string actionType, string npassw = null, string nresetpw = null) { if (actionType == "Cancel") { } if (actionType == "Update") { if (ModelState.IsValid) { try{ int type = 1; if (nresetpw == "on") { type = 2; } Guid guid = Guid.NewGuid(); string re = guid.ToString(); string Passw = re.Substring(1, 4) + re.Substring(re.Length - 5, 4); string Login = user.UserLoginName; string Fname = user.UserFirstName; string Lname = user.UserLastName; var pType = new SqlParameter { ParameterName = "@ptype", SqlDbType = System.Data.SqlDbType.Int, Value = type }; var pId = new SqlParameter { ParameterName = "@pid", SqlDbType = System.Data.SqlDbType.Int, Value = id }; var login = new SqlParameter("@plog", Login); var pass = new SqlParameter("@ppw", Passw); var fname = new SqlParameter("@pfnam", Fname); var lname = new SqlParameter("@plnam", Lname); var retor = new SqlParameter { ParameterName = "@ret", SqlDbType = System.Data.SqlDbType.NVarChar, Direction = System.Data.ParameterDirection.Output, Value = " " }; _dbContext.Database.ExecuteSqlRaw("uspUpdUser @pid,@ptype,@plog,@ppw,@pfnam,@plnam,@ret OUT", pId, pType, login, pass, fname, lname, retor); string mensaje = (string)retor.Value; //"0" ok //"1" incorrect Throw exception //_dbContext.TUsers.Add(user); //_dbContext.SaveChanges(); if (type == 2 || npassw != null) { if (npassw != null) { Passw = npassw; } CreateViewBags(0, id); ViewData["panel"] = 5; ViewData["Coment"] = "PassChanged"; ViewData["NewPw"] = Passw; return(View(user)); } } catch (Exception ex) { string mensaje = ex.Message; return(View("Error")); } } } /* * else { * CreateViewBags(0,id); * ViewData["panel"]=5; * return View(user); * } */ CreateViewBags(0, id); ViewData["panel"] = 5; return(RedirectToAction("Index", new{ panel = 5, FaId = 0 })); }
private void sendMailIdPassword(string mailAddress) { //###### Cria Email ###### //System.Net.Mail MailMessage email = new MailMessage(); //Atribui codificação para o BODY e o ASSUNTO //email.SubjectEncoding = System.Text.Encoding.GetEncoding("ISO-8859-1"); email.BodyEncoding = System.Text.Encoding.GetEncoding("ISO-8859-1"); TUser tUser = DbControl.getInstance().getUserByEmail(mailAddress); if (tUser == null) { Response.Write("<script type='text/javascript'>alert('Mail address not registered!');</script>"); return; } string emailRecipient = tUser.email; //Atribui email real email.To.Add(new MailAddress(emailRecipient)); //Atribui remetente email.From = new MailAddress("*****@*****.**", "ClassX"); //Atribui assunto email.Subject = "ClassX - Recover of ID and PASSWORD"; //Tipo de Corpo do Email email.IsBodyHtml = true; email.Body = "<font face='arial' size='2'>"; email.Body += "<b>CLASS EXTENDER - Recover of ID and PASSWORD</b><br><br>"; email.Body += "Hy " + tUser.name + ", this is an automatic message, don't answer please!<br>"; email.Body += "Someone (probably you) requested to recover your ID and PASSWORD<br>"; email.Body += " for Class Extender (http://ideias.inf.puc-rio.br/classx).<br>"; email.Body += " <b>ID: </b>" + tUser.id + "<br>"; email.Body += " <b>PASSWORD: </b>" + DbControl.getInstance().getUserPassword(tUser.id).ToString() + "<br><br>"; email.Body += "If someone else made this request, ignore this message."; //###### Send Mail ###### //try //{ //=========== Send Mail ============= System.Net.Mail.SmtpClient smtpClient = new System.Net.Mail.SmtpClient(); smtpClient.Host = "smtp.gmail.com"; System.Net.NetworkCredential smtpUserInfo = new System.Net.NetworkCredential("*****@*****.**", "flashclassx"); smtpClient.Credentials = smtpUserInfo; smtpClient.EnableSsl = true; smtpClient.Send(email); Response.Write("<script type='text/javascript'>alert('Your ID and PASSWORD has been sent to your email account!');</script>"); //======================================= //} /*catch * { * Response.Write("<script type='text/javascript'>alert('Error trying to send your recovery email!');</script>"); * return; * }*/ //########################### }
this HttpContext context, TUser user, string name) where TUser : class
public ActionResult SignIn(TUser user) { try { byte[] hashedValueOfPassword = sha512.ComputeHash(Encoding.UTF8.GetBytes(user.Password)); string hexOfValuePassword = BitConverter.ToString(hashedValueOfPassword); user.Password = hexOfValuePassword; if (Membership.ValidateUser(user.UserEmail, user.Password)) { int id = objBs.tuserBs.GetAll().Where(x => x.UserEmail == user.UserEmail).FirstOrDefault().UserId; var tuser = objBs.tuserBs.GetByID(id); tuser.LastLogin = DateTime.Now; objBs.tuserBs.Update(tuser); FormsAuthentication.SetAuthCookie(user.UserEmail, false); return RedirectToAction("Index", "Home", new { sms = "Login Successfully" }); } else { return RedirectToAction("Index", "Login", new { sms = "Failed! " + "user or password is incorrected" }); } } catch (Exception ex) { FormsAuthentication.SignOut(); return RedirectToAction("Index", "Login", new { sms = "Failed! " + ex.Message }); } }
public AbpLoginResult(TUser user, ClaimsIdentity identity) : this(AbpLoginResultType.Success) { User = user; Identity = identity; }
public TLeaveApplicationViewModel(TLeaveApplication p, TUserDepartment d, TUser u) { iv_Leave = p; iv_Department = d; iv_User = u; }
public bool Update(TUser user) { return(controller.Update(TransporterToModel(user))); }
public ActionResult DeleteUser(TUser user) { try { if (user.UserEmail != user.Password) { return RedirectToAction("DeleteUser", "Login", new { sms = "Failed! " + "E-mail not matched." }); } //check if existed. var tuser = objBs.tuserBs.GetByEmail(user.UserEmail); if (tuser != null) { objBs.tuserBs.Delete(tuser.UserId); //FormsAuthentication.SetAuthCookie(user.UserEmail, false); return RedirectToAction("DeleteUser", "Login", new { sms = "User deleted successfully" }); } else { return RedirectToAction("DeleteUser", "Login", new { sms = "Failed! " + "User not existed" }); } } catch (Exception ex) { FormsAuthentication.SignOut(); return RedirectToAction("DeleteUser", "Login", new { sms = "Failed! " + ex.Message }); } }
TUser Update(TUser Entity);
TUser Delete(TUser Entity);
public async Task <ResultWrapper <CreateSupplierOutput> > Handle(CreateSupplierCommand request, CancellationToken cancellationToken) { ResultWrapper <CreateSupplierOutput> createUserResult = new ResultWrapper <CreateSupplierOutput>(); try { GenderEnum GenderEn = GenderEnum.NULL; if (!Enum.TryParse <GenderEnum>(request.Gender.ToString(), true, out GenderEn)) { createUserResult.Status = false; createUserResult.Message = "Gender value is invalid!"; return(createUserResult); } TUser tUser = _dbContext.TUser.FirstOrDefault(x => x.Email == request.Email); if (tUser == null) { tUser = new TUser() { Email = request.Email, FireBaseId = request.FireBaseId, Enabled = true, Gender = request.Gender, Role = request.Role, FirstName = request.FirstName, LastName = request.LastName, Address = request.Address, PostalCode = request.PostalCode, Phone = request.Phone, TRegionCityId = request.RegionCityId, RestaurantName = request.RestaurantName, ShareAccount = request.ShareAccount, SharePercent = request.SharePercent, Lat = request.Lat, Lng = request.Lng }; _dbContext.TUser.Add(tUser); } else { tUser.FireBaseId = request.FireBaseId; tUser.Gender = request.Gender; tUser.FirstName = request.FirstName; tUser.LastName = request.LastName; tUser.Address = request.Address; tUser.PostalCode = request.PostalCode; tUser.Phone = request.Phone; tUser.TRegionCityId = request.RegionCityId; tUser.RestaurantName = request.RestaurantName; tUser.ShareAccount = request.ShareAccount; tUser.SharePercent = request.SharePercent; tUser.Lat = request.Lat; tUser.Lng = request.Lng; } await _dbContext.SaveChangesAsync(); createUserResult.Status = true; createUserResult.Result = new CreateSupplierOutput() { Id = tUser.Id, Email = tUser.Email, FireBaseId = tUser.FireBaseId }; } catch (Exception ex) { createUserResult.Status = false; createUserResult.Message = ex.Message; } return(createUserResult); }
public ActionResult ResetPassword(TUser user, string oldPassword, string keyPassword) { try { byte[] hashedConfirmPassword = sha512.ComputeHash(Encoding.UTF8.GetBytes(user.ConfirmPassword)); string hexConfirmPassword = BitConverter.ToString(hashedConfirmPassword); byte[] hashedValueOfPassword = sha512.ComputeHash(Encoding.UTF8.GetBytes(user.Password)); string hexOfValuePassword = BitConverter.ToString(hashedValueOfPassword); user.ConfirmPassword = hexConfirmPassword; user.Password = hexOfValuePassword; if (user.ConfirmPassword != user.ConfirmPassword) { return RedirectToAction("ResetPassword", "Login", new { sms = "Failed! " + "Confirm password incorrect." }); } //check if existed. var tuser = objBs.tuserBs.GetByEmail(user.UserEmail); if (tuser != null) { objBs.tuserBs.Update(user); //FormsAuthentication.SetAuthCookie(user.UserEmail, false); return RedirectToAction("ResetPassword", "Login", new { sms = "Password changed successfully" }); } else { return RedirectToAction("ResetPassword", "Login", new { sms = "Failed! " + "User not existed" }); } } catch (Exception ex) { FormsAuthentication.SignOut(); return RedirectToAction("ResetPassword", "Login", new { sms = "Failed! " + ex.Message }); } }