public static async Task <TServiceResult <Token> > SignUpAsync(this IActions <Token> repo, UserVM data, IAuthActions <Token> dataManager) { var u = data.MapProp <UserVM, AppUser>(new AppUser()); var result = await dataManager.GetUserManager().CreateAsync(u, data.Password); if (result.Succeeded) { return(CreateToken(repo, data, dataManager.GetSecurityKey())); } return(new TServiceResult <Token>(null, "", false)); }
public static async Task <TServiceResult <Token> > LoginAsync(this IActions <Token> repo, UserVM data, IAuthActions <Token> dataManager) { Token t = new Token(); var user = data.MapProp <UserVM, AppUser>(new AppUser()); var res = await dataManager.GetSigningManager().PasswordSignInAsync(user.UserName, data.Password, true, true); if (!res.Succeeded) { return(new TServiceResult <Token>(null, "not found", false)); } user = await dataManager.GetUserManager().FindByNameAsync(user.UserName); if (!await dataManager.GetUserManager().IsInRoleAsync(user, "User")) { /* * add memeber to roll */ } return(CreateToken(repo, data, dataManager.GetSecurityKey())); }