Example #1
0
        public AuthResult New(NewRequest newRequest)
        {
            AuthResult authResult = null;

            try
            {
                authResult = AccountHandler.CreateUser(newRequest);
                if (authResult.AuthStatus == AuthStatus.OK)
                {
                    authResult = this.Login(new LoginRequest()
                    {
                        UserName = newRequest.Email, Password = newRequest.Password
                    });
                }
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
                authResult.AuthStatus = AuthStatus.ERROR;
            }

            if (authResult.AuthStatus != AuthStatus.OK)
            {
                ServiceHelper.ThrowBadRequest <AuthResult>(Request, authResult);
            }

            return(authResult);
        }