Exemplo n.º 1
0
        public ValueTask <Account> Get()
        {
            HttpContextCookieProvider httpCookie = new HttpContextCookieProvider(HttpContext);
            var id = httpCookie.GetCookie(HttpContext.User.Identity.Name);

            return(_accountService.LoadOrCreateAsync(id));
        }
Exemplo n.º 2
0
        public async Task Login([FromBody] UserName userName)
        {
            var account = await _db.FindByUserNameAsync(userName.userName);


            if (account != null)
            {
                //TODO 1: Generate auth cookie for user 'userName' with external id
                HttpContext.User.AddIdentity(new ClaimsIdentity("userNa", userName.userName, account.Role));

                HttpContextCookieProvider HttpCookie = new HttpContextCookieProvider(HttpContext);
                HttpCookie.SetCookie(account.UserName, account.ExternalId);
            }

            //TODO 2: return 404 if user not found
            else
            {
                Response.StatusCode = (int)HttpStatusCode.NotFound;
            }
        }