public async Task <IEnumerable <QuestionModel> > GetUserQuestionsAsync(UserNameModel userName) { IEnumerable <UserQuestion> userQuestions = await _unitOfWork .AuthenticationRepository .GetUserQuestionsAsync(userName.UserName); List <int> questionNumbers = new List <int>(); Random random = new Random(); for (int i = 0; i < 3; i++) { int value = random.Next(0, 8); while (questionNumbers.Any(num => num == value)) { value = random.Next(0, 8); } questionNumbers.Add(value); } userQuestions = userQuestions .Where(uq => questionNumbers .Any(num => num == uq.QuestionId ) ); return(userQuestions.Select(uq => new QuestionModel { Id = uq.QuestionId, Value = uq.Question.Value })); }
private UserProfileModel BuildUserProfileModel(UserNameModel nameModel) { var profile = GetUserProfileModel(); profile.Name = nameModel; return(profile); }
public IActionResult ChangeName([Bind(Prefix = "Name")] UserNameModel model) { if (!ModelState.IsValid) { return(CorrectErrors(BuildUserProfileModel(model), "name")); } var user = _userAccountService.GetByID(User.GetId()); _userAccountService.RemoveClaims(user.ID, new UserClaimCollection(user.Claims.Where(claim => claim.Type == "given_name" || claim.Type == "family_name" || claim.Type == "name"))); var claims = new UserClaimCollection(); claims.Add("given_name", model.GivenName); claims.Add("family_name", model.FamilyName); claims.Add("name", string.Join(" ", new string[] { model.GivenName, model.FamilyName } .Where(name => !string.IsNullOrWhiteSpace(name)))); _userAccountService.AddClaims(user.ID, claims); return(RedirectToAction("Edit", new { changed = true })); }
public ActionResult EditUserName(int id) { UserNameModel model = dal.GetUserNameById(id); var gameType = dal.GetGameTypes(); ViewBag.GameType = new SelectList(gameType, "Id", "GameType"); return(PartialView("UserNameModal", model)); }
public ActionResult AddUserName() { UserNameModel model = new UserNameModel(); var gameType = dal.GetGameTypes(); ViewBag.GameType = new SelectList(gameType, "Id", "GameType"); return(PartialView("UserNameModal", model)); }
public void SetAuthCookie(string userid, bool persistant) { var model = new UserNameModel(); model.UserId = userid; model.CustomerId = CustomerId.ToString(); FormsAuthentication.SetAuthCookie(System.Web.Helpers.Json.Encode(model), persistant); }
public async Task <IActionResult> UserUnlocked([FromBody] UserNameModel model) { var user = await _store.Read(CreateUserId(model.UserName)); user.IsLockedOut = false; await _store.Save(user); return(Ok()); }
public async Task <IActionResult> GetQuestions(UserNameModel authModel) { IEnumerable <QuestionModel> questions = await _authenticationService.GetUserQuestionsAsync(authModel); if (!questions.Any()) { return(BadRequest()); } return(Ok(questions)); }
public async Task <IHttpActionResult> UpdateUserName([FromUri] string id, [FromBody] UserNameModel newUserName) { //throws 400 var validator = new UserNameModelValidator(); validator.ValidateAndThrow(newUserName); await _service.UpdateUserNameAsync(id, newUserName.UserName); return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <ActionResult> ReAssignMember(int Id, string UserName, int UserNameId, string Password, string Status) { try { MemberModel memberData = dal.GetMemberById(Id); memberData.UserName = UserName; //generatedPassword //var genPassword = System.Web.Security.Membership.GeneratePassword(8, 0); //UnicodeEncoding uEncode = new UnicodeEncoding(); //byte[] data = uEncode.GetBytes(genPassword); //data = new System.Security.Cryptography.SHA512Managed().ComputeHash(data); string Pass = Password; UnicodeEncoding uEncode = new UnicodeEncoding(); byte[] data = uEncode.GetBytes(Password); data = new System.Security.Cryptography.SHA512Managed().ComputeHash(data); memberData.Password = Convert.ToBase64String(data); dal.ReAssignMember(memberData); var message = "Selamat anda berhasil registrasi di macan303.com. Jenis game yang anda mainkan adalah " + memberData.GameTypeName.ToString() + ". Silahkan login dengan Username: "******". Password: "******"."; var url = "https://reguler.zsms.us/apps/smsapi.php?userkey=1ilo23&passkey=pass.123&nohp=" + memberData.PhoneNumber + "&pesan=" + message; var client = new HttpClient(); HttpResponseMessage response = await client.GetAsync(url); response.EnsureSuccessStatusCode(); if (Status == "list") { dal.UpdateUserName(UserNameId); } else if (Status == "manual") { UserNameModel um = new UserNameModel(); um.UserName = UserName; dal.InsertUserNameAssigned(um); } dal.UpdateNotifications(memberData.Id, "member"); Session["message"] = "Member is successfully assigned"; Session["requestStatus"] = "Success"; return(RedirectToAction("Index")); } catch { Session["message"] = "Unable to perform this request"; Session["requestStatus"] = "Error"; return(RedirectToAction("Index")); } }
public void SignOutCustomer() { if (UserId != null) { var model = new UserNameModel(); model.UserId = UserId; model.CustomerId = null; FormsAuthentication.SetAuthCookie(System.Web.Helpers.Json.Encode(model), false); } else { FormsAuthentication.SignOut(); } }
public void SignOutUser() { if (CustomerId.HasValue) { var model = new UserNameModel(); model.UserId = null; model.CustomerId = CustomerId.ToString(); FormsAuthentication.SetAuthCookie(System.Web.Helpers.Json.Encode(model), false); } else { FormsAuthentication.SignOut(); } }
public async Task <IActionResult> SaveName([FromBody] UserNameModel nameModel) { if (nameModel.IsNull() || string.IsNullOrWhiteSpace(nameModel.FirstName) || string.IsNullOrWhiteSpace(nameModel.DisplayName)) { return(BadRequest()); } if (await _profileEditManager.SaveNameDetails(nameModel)) { return(Ok(true)); } return(StatusCode(StatusCodes.Status304NotModified, this)); }
public async Task <bool> SaveNameDetails(UserNameModel nameModel) { var result = await _userRepository.UpdateNameDetails( new User { Id = UserContext.Current.UserId, FirstName = nameModel.FirstName, LastName = nameModel.LastName, OrgName = nameModel.OrgName, DisplayName = nameModel.DisplayName }); return(result); }
public ActionResult AddUserName(UserNameModel userNameModel) { try { dal.InsertUserName(userNameModel); Session["message"] = "User Name is successfully added"; Session["requestStatus"] = "Success"; return(RedirectToAction("Index")); } catch { Session["message"] = "Unable to perform this request"; Session["requestStatus"] = "Error"; return(RedirectToAction("Index")); } }
public IActionResult UnFollowUser([FromBody] UserNameModel model) { FollowUserReturn ret = new FollowUserReturn(); //try //{ var user = HttpContext.User; Claim idClaim = User.FindFirst("sub"); ret = _userInfoDataService.UnFollowUser(model.Username, idClaim.Value); return(Ok(Json(ret))); //} //catch (System.Exception ex) //{ // ret.IsActionSucceed = false; // ret.ErrorInformation.UserInformation = ex.Message; // return Ok(Json(ret)); //} }
public IActionResult FollowUser([FromBody] UserNameModel model) { FollowUserReturn ret = new FollowUserReturn(); var user = HttpContext.User; Claim idClaim = User.FindFirst("sub"); Claim usernameClaim = User.FindFirst("nickname"); ret = _userInfoDataService.FollowUser(model.Username, idClaim.Value); if (ret.IsActionSucceed && !string.IsNullOrEmpty(ret.FollowedUserId)) { _bus.Publish(new UserFollowedUserAction() { DateUtcAction = DateTime.UtcNow, FollowedUserId = ret.FollowedUserId, FollowingUsername = usernameClaim.Value, FollowingUserId = idClaim.Value }); } return(Ok(Json(ret))); }
public IHttpActionResult CheckName(UserNameModel model) { var exists = (db.Users.FirstOrDefault(u => u.UserName == model.username) != null); return(Ok(exists ? "exists" : "new")); }