Example #1
0
		public async Task<ActionResult> Login(LoginViewModel model)
		{
			var user = await ExternalApi.Post<User>(UrlUtilities.Login, new Tuple<string, string>(model.Username, model.Password));

			if (user != null)
			{
				Auth(user);
				return RedirectToAction("Index");
			}
			return RedirectToAction("Index", "Home");
		}
Example #2
0
		public async Task<ActionResult> Register(LoginViewModel model)
		{
			var user = new User()
			{
				Email = model.Email,
				FirstName = model.FirstName,
				LastName = model.LastName,
				Password = PasswordAuthenticator.CreateHash(model.Password),
				Id = -1
			};

			user = await ExternalApi.Post<User>(UrlUtilities.User, user);

			if (user != null && user.Id >= 0)
			{
				Auth(user);
				return RedirectToAction("Index");
			}

			return RedirectToAction("Index", "Home");
		}