예제 #1
0
        public async Task SignIn(HttpContext httpContext, UserViewModel usuario)
        {
            var usrRetorno = await _usuarioIntegration.LoginAsync(new UserLogin
            {
                Login = usuario.Usuario,
                Senha = usuario.Senha,
            });

            if (usrRetorno?.Success != null && (bool)usrRetorno?.Success)
            {
                var identity  = new ClaimsIdentity(GetUserClaims(_mapper.Map <TokenModelView>(usrRetorno.ObjectReturn)), "ApplicationCookie");
                var principal = new ClaimsPrincipal(identity);
                await httpContext.SignInAsync(principal, new AuthenticationProperties
                {
                    IsPersistent = true,
                    ExpiresUtc   = DateTime.UtcNow.AddDays(7) // todo: configure this value
                });

                return;
            }
        }
예제 #2
0
        public async Task SignIn(HttpContext httpContext, UserViewModel usuario)
        {
            var usrRetorno = await _usuarioIntegration.LoginAsync(new UserLogin
            {
                Login    = usuario.Usuario,
                Password = usuario.Password,
            });

            if (usrRetorno?.Sucesso != null && (bool)usrRetorno?.Sucesso)
            {
                var identity  = new ClaimsIdentity(GetUserClaims(_mapper.Map <TokenModelView>(usrRetorno.objetoDeRetorno)), "ApplicationCookie");
                var principal = new ClaimsPrincipal(identity);
                await httpContext.SignInAsync(principal, new AuthenticationProperties
                {
                    IsPersistent = true,
                    ExpiresUtc   = DateTime.UtcNow.AddDays(7)
                });

                return;
            }
        }