public async void Authenticate_HappyPath() { var user = fixture.Create <User>(); var password = fixture.Create <string>(); await userRepo.Create(user, password); var res = await userRepo.Authenticate(user.Username, password); Assert.Equal(res.Username, user.Username); }
public ActionResult FacebookCallback(string Code) { try { var fbInfo = GetFaceBookInfoOnCallback(Code, Url.Action("FacebookCallback")); var user = UserRepo.GetSingle(FBUserID: (string)fbInfo.id); if (user != null) { Session.SetUser(UserRepo.Authenticate(user.Username, user.Password, true)); var redirectUrl = TempData.GetRedirectUrl(); if (redirectUrl != null) { return(Redirect(redirectUrl)); } return(RedirectToAction("Index", "Home")); } TempData.SetRegistrationModel(new RegistrationModel { FirstName = fbInfo.first_name, LastName = fbInfo.last_name, Email = fbInfo.email, FBUserID = fbInfo.id }); return(RedirectToAction("Index", "Home")); } catch (Exception e) { HandleStandardMessaging(true); Utilities.LogError(e, Request.Url.ToString()); return(RedirectToAction("Index", "Home")); } }
public ActionResult LogIn(string Username, string Password) { Session.SetUser(UserRepo.Authenticate(Username, Password)); return(Json(new { Success = Session.IsAuthorized() }, JsonRequestBehavior.AllowGet)); }