Esempio n. 1
0
        public IHttpActionResult Post([FromBody] Models.LoginRequest value)
        {
            var result = userLoginService.Login(value.EmailAddress, value.Password);

            if (result == null)
            {
                return(NotFound());
            }
            else
            {
                return(Ok(result));
            }
        }
Esempio n. 2
0
        public ActionResult Post([FromBody] Models.LoginRequest value)
        {
            var result = loginService.Login(value.EmailAddress, value.Password);

            if (result == null)
            {
                return(Unauthorized());
            }
            else
            {
                return(Ok(result));
            }
        }
Esempio n. 3
0
        private async void GoWorkout(object sender, EventArgs e)
        {
            UsersModel user         = new UsersModel();
            var        respostaUser = new Message <List <UsersModel> >();

            try
            {
                ActiveLoading.IsRunning = true;
                ActiveLoading.IsVisible = true;

                respostaUser = await _service.Login(txtEmail.Text, txtPassword.Text);

                if (respostaUser.IsSuccess)
                {
                    for (var i = 0; i < respostaUser.Data.Count; i++)
                    {
                        user = respostaUser.Data[i];
                    }

                    ActiveLoading.IsRunning = false;
                    ActiveLoading.IsVisible = false;



                    if (respostaUser.IsSuccess)
                    {
                        //App.Current.MainPage = new NavigationPage(new Workout(user));
                        App.Current.MainPage = new NavigationPage(new GridMenu(user));
                    }
                    else
                    {
                        await DisplayAlert("Erro!", "Erro inesperado.", "OK");
                    }
                }
                else
                {
                    await DisplayAlert("Aviso!", respostaUser.ReturnMessage, "OK");
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                ActiveLoading.IsRunning = false;
                ActiveLoading.IsVisible = false;
            }
        }
        public ActionResult Login(LoginModel m)
        {
            var result = _service.Login(m.UserName, m.Password);

            if (result)
            {
                FormsAuthentication.SetAuthCookie(m.UserName, false);
                return(RedirectToAction("Index", "Home"));
            }

            else
            {
                return(View(m));
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Password_Credentials_Grant方式
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context)
        {
            if (string.IsNullOrWhiteSpace(context.Request.Query["domain"]))
            {
                await base.GrantResourceOwnerCredentials(context);
            }

            var loginService = new Services.LoginService(context.Request.Query["domain"], context.UserName, context.Password);

            if (loginService.Login())
            {
                var oAuthIdentity = new ClaimsIdentity(context.Options.AuthenticationType);
                oAuthIdentity.AddClaim(new Claim(ClaimTypes.Name, context.UserName));
                var ticket = new AuthenticationTicket(oAuthIdentity, new AuthenticationProperties());
                context.Validated(ticket);
            }

            await base.GrantResourceOwnerCredentials(context);
        }