public async Task <ActionResult> Login([FromBody] LoginTemplate loginTemplate) { var email = loginTemplate.Email; var password = loginTemplate.Password; try { if (!IsValidEmail(email)) { return(StatusCode(StatusCodes.Status400BadRequest, "Invalid email")); } if (email == null || password == null || email == "" || password == "") { return(StatusCode(StatusCodes.Status400BadRequest, "Invalid arguments")); } var token = await Storage.FindUser(email, password); return(StatusCode(StatusCodes.Status200OK, token)); } catch (ArgumentException exeption) { return(StatusCode(StatusCodes.Status404NotFound, exeption.Message)); } catch (Exception exeption) { return(StatusCode(StatusCodes.Status500InternalServerError, exeption.Message)); } }
/// <summary> /// /// </summary> /// <param name="loginForm"></param> /// <returns></returns> public Customer Login(LoginTemplate loginForm) { SetDefaultHeaders(); var customerInformation = LibrettoDatabase.CustomerIntegration.LookupByEmail(loginForm.Email); if (customerInformation == null)// || PasswordUtilities.Verify(loginForm.Password, customerInformation.Password) == false) { return(null); } return(customerInformation); }
protected override void CreateChildControls() { this.ToggleButtonStyle = ButtonStyle.Link; this.Controls.Clear(); if (BodyTemplate == null) { BodyTemplate = new LoginTemplate(UsernameTitle, UsernamePlaceholder, PasswordTitle, PasswordPlaceholder, LoginButtonStyle, LoginButtonIcon, LoginButtonText); ((LoginTemplate)BodyTemplate).LoginButton.Click += onClick; } base.CreateChildControls(); }
public ActionResult LogOn(LoginTemplate login, string returnUrl) { User result = db.Users.AsNoTracking() .Where(m => m.email == login.email) .Where(m => m.password == login.password) .SingleOrDefault(); if (result != null) { Session["logged"] = true; Session["user"] = result; return(RedirectToAction("Index", "Home")); } }
/// <summary> /// /// </summary> /// <param name="loginForm"></param> /// <returns></returns> public bool Login(LoginTemplate loginForm) { Proxy = new StoreServiceClient(new InstanceContext(this)); if (Proxy.ClientCredentials == null) { return(false); } try { Proxy.ClientCredentials.UserName.UserName = loginForm.Email; Proxy.ClientCredentials.UserName.Password = loginForm.Password; var clerkInformation = Proxy.Profile(); if (clerkInformation != null) { Session = clerkInformation; } else { return(false); } RefreshBooks(); Transactions.Clear(); Transactions.AddRange(Proxy.ListOrders()); Transactions.AddRange(Proxy.ListPurchases()); if (Proxy.State != CommunicationState.Faulted) { Proxy.Subscribe(); } return(true); } catch { return(false); } }
public async Task <IActionResult> OnPostLogin([FromBody] LoginTemplate login) { var result = await Auth.Login(login) as ObjectResult; if (result.StatusCode == 200) { var token = result.Value as UserToken; var options = new CookieOptions { SameSite = SameSiteMode.Lax, Expires = new DateTimeOffset(DateTime.Now.AddMonths(6)) }; HttpContext.Response.Cookies.Append("TraverlApp.fun.UserId", token.UserId.ToString(), options); HttpContext.Response.Cookies.Append("TraverlApp.fun.Token", token.Token, options); return(StatusCode(StatusCodes.Status200OK, "Login success")); } else { return(result); } }
// methods protected internal override void CreateChildControls () { Controls.Clear (); ITemplate template = LayoutTemplate; if (template == null) template = new LoginTemplate (this); LoginTemplateContainer.InstantiateTemplate (template); Controls.Add (container); IEditableTextControl editable; editable = container.UserNameTextBox as IEditableTextControl; if (editable != null) { editable.Text = UserName; editable.TextChanged += new EventHandler (UserName_TextChanged); } else throw new HttpException ("LayoutTemplate does not contain an IEditableTextControl with ID UserName for the username."); editable = container.PasswordTextBox as IEditableTextControl; if (editable != null) editable.TextChanged += new EventHandler (Password_TextChanged); else throw new HttpException ("LayoutTemplate does not contain an IEditableTextControl with ID Password for the password."); ICheckBoxControl checkBox = container.RememberMeCheckBox as ICheckBoxControl; if (checkBox != null) checkBox.CheckedChanged += new EventHandler (RememberMe_CheckedChanged); }