private async Task <LoginOutput> LoginAsync(IdentityUser user, string password) { //var result = await signInManager.PasswordSignInAsync(username, password, true, lockoutOnFailure: true); var result = await signInManager.PasswordSignInAsync(user, password, true, false); if (result.Succeeded) { //var user = userManager.FindByNameAsync(username).Result; var token = await generateToken.GetToken(user.UserName, user); return(new LoginOutput { CustomerId = new Guid(user.Id), Name = user.UserName, Token = token }); } return(null); }
private async Task <RegisterOutput> RegistrationAsync(string username, string password) { var user = new IdentityUser { UserName = username }; var result = await userManager.CreateAsync(user, password); if (result.Succeeded) { await signInManager.SignInAsync(user, isPersistent : false); var token = await generateToken.GetToken(username, user); return(new RegisterOutput { CustomerId = new Guid(user.Id), Token = token }); } return(null); }
private async Task <RegisterOutput> RegistrationAsync(Input input) { var user = new AppIdentityUser { Id = Guid.NewGuid().ToString(), UserName = input.Name.ToString(), Email = input.Email.ToString(), PhoneNumber = input.Mobile.ToString(), SSN = input.SSN.ToString() }; var Result = await userManager.CreateAsync(user, input.Password.ToString()); if (Result.Succeeded) { //var debug = await generateToken.GetToken(username, user); //return new Guid(user.Id); await signInManager.SignInAsync(user, isPersistent : false); var token = await generateToken.GetToken(input.Name.ToString(), user); return(new RegisterOutput { user = user, Token = token }); } return(null); }
private async Task <RegisterOutput> RegistrationAsync(string username, string password, string email, string mobile) { var user = new IdentityUser { UserName = username, Email = email, PhoneNumber = mobile }; var Result = await userManager.CreateAsync(user, password); if (Result.Succeeded) { //var debug = await generateToken.GetToken(username, user); //return new Guid(user.Id); await signInManager.SignInAsync(user, isPersistent : false); var token = await generateToken.GetToken(username, user); return(new RegisterOutput { CustomerId = new Guid(user.Id), Token = token }); } return(null); }