public virtual async Task <IActionResult> UserLogin([FromBody] UserLoginEvent model) { // The eventual user var validatedUser = _context.AllUsers.Where(u => u.Enabled).FirstOrDefault(x => x.Email == model.ContactInfo || x.PhoneNumber == model.ContactInfo.CleanPhone()); if (validatedUser == null) { // Our response is vague to avoid leaking information return(ResponseShell.Error("Could not find an account with that information")); } var passCheck = validatedUser.VerifyPassowrd(model.Password); if (passCheck != PasswordVerificationResult.Success) { return(ResponseShell.Error("Could not find an account with that information")); } // Get our token var token = await _tokenService.GetToken(validatedUser); // overloading the login for webadmins too if (validatedUser is WebAdmin) { return(ResponseShell.Ok($"{_config.Urls.Frontend}/{_config.Pages.AdminPage}?user={token.UserId}&token={token.Token}")); } return(ResponseShell.Ok($"{_config.Urls.Frontend}/{_config.Pages.AccountPage}?user={token.UserId}&token={token.Token}")); }
public async Task AddUserLoginEvent(UserLoginEvent userLoginEvent) { _context.AddAuditCustomField(CustomFields.AppUser, userLoginEvent.Username); await _context.UserLoginEvent.AddAsync(userLoginEvent); await _context.SaveChangesAsync(); }
public void loadLevel(string sceneName) { sceneToLoad = sceneName; UserLoginEvent login = new UserLoginEvent(); login.Send(username.text, password.text); StartCoroutine(waitFunction()); }
public async Task <IActionResult> Login([FromBody] SessionLoginRequest loginRequest) { UserLogin?login = null; bus.Listen <UserLoginEvent>((IDomainEvent e) => { UserLoginEvent loginEvent = (UserLoginEvent)e; login = loginEvent.Login; }); var result = await mediator.Command(new LoginUserCommand() { Credentials = new UserCredentials(loginRequest.Username, loginRequest.Password) }); return(login != null?Ok(login) : Unauthorized("Invalid username and/or password.") as IActionResult); }
public async Task <string> LoginAsync(string username, string password) { var userInfo = StateData; var hashPassword = PasswordHelper.HashPassword(userInfo.Secret, password); if (username != userInfo.Username || hashPassword != userInfo.Password) { return(null); } var eventData = new UserLoginEvent(); var evt = this.CreateEvent(eventData); await Claptrap.HandleEventAsync(evt); var jwt = CreateJwt(UserId, userInfo.Secret); return(jwt); }
public async Task CheckLogingInUser() { // Call just in case of test called alone var temp = Constants.Testing.TempUsers.First(); var json = await _fixture.Post <SimpleSuccess>($"{Constants.V1Prefix}/{Constants.GenericUserEndpoint}/create", temp); var queryParams = new FormUrlEncodedContent(new KeyValuePair <string, string>[] { new KeyValuePair <string, string>("token", _fixture.FakeToken), }); // validate just in case var resResirectToPassword = await _fixture.Get($"{Constants.V1Prefix}/{Constants.GenericUserEndpoint}/validate", queryParams); var queryPassParam = new FormUrlEncodedContent(new KeyValuePair <string, string>[] { new KeyValuePair <string, string>("token", _fixture.FakeToken), new KeyValuePair <string, string>("password", Constants.Testing.DefaultUserPass), }); // set the password just in case await _fixture.Post <TokenInfo>($"{Constants.V1Prefix}/{Constants.GenericUserEndpoint}/password", queryPassParam); var modelEvent = new UserLoginEvent() { ContactInfo = Constants.Testing.TempUsers.First().Email, Password = Constants.Testing.DefaultUserPass }; var token = await _fixture.Post <TokenInfo>($"{Constants.V1Prefix}/{Constants.GenericUserEndpoint}/login", modelEvent); Assert.NotNull(token.Result); Assert.NotNull(token.Result.Token); Assert.True(token.Result.UserId != Guid.Empty.ToString()); }
public void HandleEvent(UserLoginEvent eventToDispatch) { FillUserLocations(eventToDispatch.InMemoryUser); }
public static void InvokeUserLoginEvent(UserLoginEventArgs args) { UserLoginEvent?.Invoke(args); }
private void InitData(string fileName, string approvalBandString, decimal approvalLimit, out List <CostUser> users, out ApprovalBand approvalBand, out Smo smo, out UserLoginEvent userLoginEventObject) { var stringJson = GetJsonString(fileName).Result; userLoginEventObject = JsonConvert.DeserializeObject <UserLoginEvent>(stringJson); users = new List <CostUser> { new CostUser { Id = Guid.NewGuid(), UserBusinessRoles = new List <UserBusinessRole> { new UserBusinessRole { BusinessRole = new BusinessRole { Key = Constants.BusinessRole.BrandManager, Value = Constants.BusinessRole.BrandManager } } }, GdamUserId = "58adcba90c885409f1f47c57" }, new CostUser { Id = Guid.NewGuid(), Email = ApprovalMemberModel.BrandApprovalUserEmail, UserBusinessRoles = new List <UserBusinessRole> { new UserBusinessRole { BusinessRole = new BusinessRole { Key = Constants.BusinessRole.BrandManager, Value = Constants.BusinessRole.BrandManager } } }, GdamUserId = "4ef31ce1766ec96769b399c0" } }; approvalBand = new ApprovalBand { ApprovalLimit = approvalLimit, BusinessRole = users.First(a => a.GdamUserId == "58adcba90c885409f1f47c57").UserBusinessRoles.First().BusinessRole, Id = Guid.NewGuid(), Band = -1, StringBand = approvalBandString }; smo = new Smo { Countries = new List <Country> { new Country { Cities = new List <City>(), Iso = [email protected], Name = "POLAND" } }, Key = Constants.Smo.WesternEurope, Value = Constants.Smo.WesternEurope }; }
public async Task AddUserLoginEvent(UserLoginEvent userLoginEvent) { await _context.UserLoginEvent.AddAsync(userLoginEvent); await _context.SaveChangesAsync(); }
public void Login(UserLoginEvent loginEvent) { var d = new Dictionary<string, object> { {"Username", loginEvent.LoginName}, {"Password", loginEvent.LoginPassword} }; var @event = SentRequestEvent.CreateRequestEvent("Account.json/LogOn", d); @event.Result = (a, b) => { var r = b.GetPostData<int>(); if(r == 1) { //��ȡ��¼���� GetCurrentUser(delegate(IUser user, IRequestParam param) { loginEvent.LoginUser = user; loginEvent.Callback(r, param); }); } else { loginEvent.Callback(r, a); } }; EventAggregator.Publish(@event); }
/// <summary> /// ִ���û���¼���¼� /// </summary> /// <param name="event">The @event.</param> public void OnLogggin(UserLoginEvent @event) { AccountService.Login(@event); }
public static void OnAfterUserLogin(EventArgs e) { UserLoginEvent?.Invoke(null, e); }
public async Task Execute(UserLoginEvent input) { await Task.Delay(1); Console.WriteLine($"欢迎登录:{input.Name},登录时间为{input.LoginTime}"); }
// Hard coded login. This should be removed when a login system is added to the HL-Client public void login() { UserLoginEvent login = new UserLoginEvent(); login.Send(username, password, FlowClient.CLIENT_HOLOLENS); }
public virtual Task Handle(UserLoginEvent message) { return(Task.CompletedTask); }
public void HandleEvent(UserLoginEvent @event) { _redisHelper.StringSet(string.Format(ONLINE_USER_SIGN_KEY_FMT, @event.Signature), string.Format("{0}{1}", @event.UserId, @event.Token), TimeSpan.FromDays(31)); }