Пример #1
0
        public ApiIdentity(User user)
        {
            if (user == null)
            {
                throw new ArgumentNullException("User is null");
            }

            User = user;
        }
Пример #2
0
        public SignIn SignUp(SignUp model)
        {
            var salt = SecurityHelper.GenerateSalt();

            var passwordHash = SecurityHelper.GeneratePasswordHash(model.Password+salt);

            var securityToken = SecurityHelper.GenerateSecurityToken();

            var user = new User(model.Email, passwordHash) { Salt = salt, FirstName = model.FirstName, LastName = model.LastName, Token = securityToken };

            using (var db = _documentStore.OpenSession())
            {
                db.Store(user);
                db.SaveChanges();
            }

            return SignInUser(user);
        }
Пример #3
0
 public static void SignInUser(User user)
 {
     System.Web.HttpContext.Current.User = new GenericPrincipal(new ApiIdentity(user), new string[] { });
 }
Пример #4
0
        private SignIn SignInUser(User user)
        {
            UserManagement.SignInUser(user);

            return new SignIn() { FirsName = user.FirstName, LastName = user.LastName, Id = user.Id, Token = user.Token };
        }