Example #1
0
        public IHttpActionResult Authorize([FromBody] LoginInformation loginInformation)
        {
            AuthorizationTokenInfo token;

            try
            {
                token = _authorizer.Authorize(loginInformation.Mail,
                                              new Password(loginInformation.Password));
            }
            catch (AccountNotFoundException ex)
            {
                return(Content(HttpStatusCode.Unauthorized, ex.Message));
            }
            catch (IncorrectPasswordException ex)
            {
                return(Content(HttpStatusCode.Unauthorized, ex.Message));
            }
            if (!_authorizer.CheckProfileCompleteness(loginInformation.Mail))
            {
                var userId   = _authorizer.GetUserByMail(loginInformation.Mail).UserId;
                var tokenReg = _authorizer.SaveProfileCompletenessConfirmationRequest(userId);
                return(Ok(new ProfileIsNotCompletedResponse(tokenReg)));
            }
            var account   = _authorizer.GetUserByMail(loginInformation.Mail);
            var projects  = _userManager.GetAllUserProjects(account);
            var portfolio = new List <ProjectPresentation>();

            foreach (var prj in projects)
            {
                portfolio.Add(new ProjectPresentation(prj, _userManager.GetMembers(prj)));
            }
            return(Ok(new CurrentUserPresentation(account, token, portfolio)));
        }