Exemplo n.º 1
0
        public async Task <Response> Signup([FromForm] User user)
        {
            var response = await loginBal.Signup(user);

            if (response.Status is true)
            {
                response.previousState = HttpContext.Session.GetString("PreviousState");
                var hash = await Task.FromResult <string>(
                    CryptographyHelper.GenerateHash(user.Account.Username + DateTime.Now.ToString(),
                                                    (response.Obj as User).Account.Salt));

                SessionHelper.SetWebsiteSession(this.HttpContext.Session, hash);
                SessionHelper.SetUserSession(this.HttpContext.Session, (response.Obj as User).Id,
                                             (response.Obj as User).FullName);
                CookieHelper.SetWebsiteCookie(this.Response, hash);
                await loginBal.SetCookieForAccount(hash, (response.Obj as User).Account);

                ViewBag.Session  = HttpContext.Session.GetString("BookStore");
                ViewBag.FullName = response.Obj as User is null
                    ? null
                    : (response.Obj as User).FullName;
                return(response);
            }
            else
            {
                return(response);
            }
        }