public async Task <Framework.WebApi.AuthenticationResponse> Logout([FromBody] Elmah.MvcCore.Models.AccountViewModels.LoginViewModel model) { // TODO: set a flag? last log out time return(new Framework.WebApi.AuthenticationResponse { Succeeded = true }); }
public async Task <Framework.WebApi.AuthenticationResponse> Login([FromBody] Elmah.MvcCore.Models.AccountViewModels.LoginViewModel model) { var user = await _userManager.FindByNameAsync(model.Email); var result = await _signInManager.CheckPasswordSignInAsync(user, model.Password, false); return(await GetAuthenticationResponse(user, result)); }
public async Task <Framework.WebApi.AuthenticationResponse> Register([FromBody] Elmah.MvcCore.Models.AccountViewModels.RegisterViewModel model) { if (!ModelState.IsValid) { return(new Framework.WebApi.AuthenticationResponse { Succeeded = false }); } var user = new Elmah.MvcCore.Models.ApplicationUser() { UserName = model.Email, Email = model.Email }; var result = await _userManager.CreateAsync(user, model.Password); if (!result.Succeeded) { return(new Framework.WebApi.AuthenticationResponse { Succeeded = false }); } else { // This is a copy from Register method in AccountController. var code = await _userManager.GenerateEmailConfirmationTokenAsync(user); var callbackUrl = Url.EmailConfirmationLink(user.Id, code, Request.Scheme); await _emailSender.SendEmailConfirmationAsync(model.Email, callbackUrl); /* * var service1 = _serviceProvider.GetRequiredService<NTierOnTime.WcfContracts.IEntityService>(); * * var response = await NTierOnTime.CoreCommonBLL.Helpers.EntityHelper.CreateNewEntity(service1, model.Email, _logger); * * if (response.BusinessLogicLayerResponseStatus == Framework.Services.BusinessLogicLayerResponseStatus.MessageOK || response.BusinessLogicLayerResponseStatus == Framework.Services.BusinessLogicLayerResponseStatus.UIProcessReady) * { * var applicationUser = await _userManager.FindByEmailAsync(model.Email); * if (applicationUser != null) * { * applicationUser.EntityID = response.Message[0].EntityID; * await _userManager.UpdateAsync(applicationUser); * } * } */ } var loginViewModel = new Elmah.MvcCore.Models.AccountViewModels.LoginViewModel { Email = model.Email, Password = model.Password }; return(await Login(loginViewModel)); }