Beispiel #1
0
        /// <summary>
        /// Sign in user
        /// </summary>
        /// <param name="model">Model</param>
        /// <returns>View</returns>
        public async Task <ActionResult> SignIn(SignInViewModel model)
        {
            string error = null;

            if (string.IsNullOrWhiteSpace(model.Email) == false && string.IsNullOrWhiteSpace(model.Password) == false)
            {
                var user = await
                           AuthenticationLogic.AuthenticateCustomer(new DtoSignIn
                {
                    EMail    = model.Email,
                    Password = model.Password
                });

                if (user != "Unauthorized")
                {
                    FormsAuthentication.RedirectFromLoginPage(model.Email, true);
                }
                else
                {
                    error = "Błąd podczas logowania";
                }
            }
            error = "Błąd podczas logowania";
            return(View(new SignInViewModel()
            {
                ErrorText = error
            }));
        }
Beispiel #2
0
        public async Task <HttpResponseMessage> AuthenticateCustomer(DtoSignIn signInData)
        {
            var authResult = await AuthenticationLogic.AuthenticateCustomer(signInData);

            var token = AuthenticationLogic.GetToken(signInData.EMail);
            var resp  = new SignInResponse {
                AuthorizationResult = authResult, Token = token
            };
            var response = Request.CreateResponse(HttpStatusCode.OK, resp);

            return(response);
        }