//[EppSecurity_Authorize] public ActionResult ChangeFirstTimePassword() { var model = new ChangePasswordContract { UserName = User.Identity.Name }; return(View(model)); }
public ActionResult ChangeFirstTimePassword() { ViewBag.Error = ""; var userData = MvcApplication.GetUserData(User.Identity.Name) ?? new UserData(); var model = new ChangePasswordContract { Username = User.Identity.Name, UserId = userData.UserId }; return(View(model)); }
public async Task <IActionResult> ChangePassword(ChangePasswordContract model) { if ((await _userManager.ChangePsw(new UserDto { Id = model.Id, Email = model.Email, Password = model.OldPassword }, model.NewPassword)).Succeeded) { return(RedirectToAction("Index", "Home")); } return(BadRequest()); }
public ActionResult ChangeFirstTimePassword(ChangePasswordContract model) { var retVal = ViewBag.IsSuccessful; if (!retVal) { return(View(model)); } return(RedirectToActionPermanent("Index", "Dashboard")); }
public async Task <IActionResult> ChangePassword([Required][FromRoute] int userId, [Required][FromBody] ChangePasswordContract contract) { var authorized = await m_userHelper.IsUserAuthorizedAsync(userId, false, false); if (!authorized) { return(Forbid()); } var user = await m_identityUserManager.FindByIdAsync(userId.ToString()); var result = await m_identityUserManager.ChangePasswordAsync(user, contract.OriginalPassword, contract.Password); if (!result.Succeeded) { return(Error(result.Errors.FirstOrDefault()?.Description, result.Errors.FirstOrDefault()?.Code)); } return(Ok()); }
public ActionResult ChangeUserPassword() { try { ViewBag.Error = ""; var userData = MvcApplication.GetUserData(User.Identity.Name); if (userData == null || userData.UserId < 1) { return(RedirectToAction("Login", new { returnUrl = "" })); } var model = new ChangePasswordContract { Username = User.Identity.Name, UserId = userData.UserId }; return(View(model)); } catch (Exception ex) { ViewBag.Error = "Error Occurred! Please try again later"; UtilTools.LogE(ex.StackTrace, ex.Source, ex.Message); return(View(new ChangePasswordContract())); } }
/// <summary> /// 处理来自客户端的同步调用请求。 /// </summary> public byte[] HandleQuery(string sourceUserID, int informationType, byte[] info) { if (informationType == InformationTypes.GetFriendIDList) { List <string> friendIDs = this.globalCache.GetFriends(sourceUserID); return(CompactPropertySerializer.Default.Serialize <List <string> >(friendIDs)); } if (informationType == InformationTypes.AddFriend) { AddFriendContract contract = CompactPropertySerializer.Default.Deserialize <AddFriendContract>(info, 0); bool isExist = this.globalCache.IsUserExist(contract.FriendID); if (!isExist) { return(BitConverter.GetBytes((int)AddFriendResult.FriendNotExist)); } this.globalCache.AddFriend(sourceUserID, contract.FriendID, contract.CatalogName); //0922 GGUser owner = this.globalCache.GetUser(sourceUserID); byte[] ownerBuff = CompactPropertySerializer.Default.Serialize <GGUser>(owner); //通知对方 this.rapidServerEngine.CustomizeController.Send(contract.FriendID, InformationTypes.FriendAddedNotify, ownerBuff, true, ESFramework.ActionTypeOnChannelIsBusy.Continue); return(BitConverter.GetBytes((int)AddFriendResult.Succeed)); } if (informationType == InformationTypes.GetAllContacts) { List <string> contacts = this.globalCache.GetAllContacts(sourceUserID); Dictionary <string, GGUser> contactDic = new Dictionary <string, GGUser>(); foreach (string friendID in contacts) { if (!contactDic.ContainsKey(friendID)) { GGUser friend = this.globalCache.GetUser(friendID); if (friend != null) { contactDic.Add(friendID, friend); } } } return(CompactPropertySerializer.Default.Serialize <List <GGUser> >(new List <GGUser>(contactDic.Values))); } if (informationType == InformationTypes.GetSomeUsers) { List <string> friendIDs = CompactPropertySerializer.Default.Deserialize <List <string> >(info, 0); List <GGUser> friends = new List <GGUser>(); foreach (string friendID in friendIDs) { GGUser friend = this.globalCache.GetUser(friendID); if (friend != null) { friends.Add(friend); } } return(CompactPropertySerializer.Default.Serialize <List <GGUser> >(friends)); } if (informationType == InformationTypes.GetContactsRTData) { List <string> contacts = this.globalCache.GetAllContacts(sourceUserID); Dictionary <string, UserRTData> dic = new Dictionary <string, UserRTData>(); foreach (string friendID in contacts) { if (!dic.ContainsKey(friendID)) { GGUser data = this.globalCache.GetUser(friendID); if (data != null) { UserRTData rtData = new UserRTData(data.UserStatus, data.Version); dic.Add(friendID, rtData); } } } Dictionary <string, int> groupVerDic = this.globalCache.GetMyGroupVersions(sourceUserID); ContactsRTDataContract contract = new ContactsRTDataContract(dic, groupVerDic); return(CompactPropertySerializer.Default.Serialize(contract)); } if (informationType == InformationTypes.GetUserInfo) { string target = System.Text.Encoding.UTF8.GetString(info); GGUser user = this.globalCache.GetUser(target); if (user == null) { return(null); } if (sourceUserID != target) //0922 { user = user.PartialCopy; } return(CompactPropertySerializer.Default.Serialize <GGUser>(user)); } if (informationType == InformationTypes.GetMyGroups) { List <GGGroup> myGroups = this.globalCache.GetMyGroups(sourceUserID); return(CompactPropertySerializer.Default.Serialize(myGroups)); } if (informationType == InformationTypes.GetSomeGroups) { List <string> groups = ESPlus.Serialization.CompactPropertySerializer.Default.Deserialize <List <string> >(info, 0); List <GGGroup> myGroups = new List <GGGroup>(); foreach (string groupID in groups) { GGGroup group = this.globalCache.GetGroup(groupID); if (group != null) { myGroups.Add(group); } } return(CompactPropertySerializer.Default.Serialize(myGroups)); } if (informationType == InformationTypes.JoinGroup) { string groupID = System.Text.Encoding.UTF8.GetString(info); JoinGroupResult res = this.globalCache.JoinGroup(sourceUserID, groupID); if (res == JoinGroupResult.Succeed) { //通知其它组成员 this.rapidServerEngine.ContactsController.Broadcast(groupID, BroadcastTypes.SomeoneJoinGroup, System.Text.Encoding.UTF8.GetBytes(sourceUserID), null, ESFramework.ActionTypeOnChannelIsBusy.Continue); } return(BitConverter.GetBytes((int)res)); } if (informationType == InformationTypes.CreateGroup) { CreateGroupContract contract = CompactPropertySerializer.Default.Deserialize <CreateGroupContract>(info, 0); CreateGroupResult res = this.globalCache.CreateGroup(sourceUserID, contract.ID, contract.Name, contract.Announce); return(BitConverter.GetBytes((int)res)); } if (informationType == InformationTypes.GetGroup) { string groupID = System.Text.Encoding.UTF8.GetString(info); GGGroup group = this.globalCache.GetGroup(groupID); return(CompactPropertySerializer.Default.Serialize(group)); } if (informationType == InformationTypes.ChangePassword) { ChangePasswordContract contract = CompactPropertySerializer.Default.Deserialize <ChangePasswordContract>(info, 0); ChangePasswordResult res = this.globalCache.ChangePassword(sourceUserID, contract.OldPasswordMD5, contract.NewPasswordMD5); return(BitConverter.GetBytes((int)res)); } return(null); }
public async Task <HttpResponseMessage> PasswordChangeAsync(int userId, ChangePasswordContract contract) { var fullPath = $"{BasePath}{userId}/changePassword"; return(await m_authorizationServiceHttpClient.SendRequestAsync(HttpMethod.Post, fullPath, contract)); }