public async Task <IActionResult> Report()
        {
            string sourceName = httpContextInfoProvider.GetSourceName();
            int    externalId = httpContextInfoProvider.GetExternalId();
            int    sourceId   = await sourceService.GetSourceIdByName(sourceName);

            ProfileDTO profile = await profileService.GetProfileBySourceIdAsync(sourceId, externalId);

            ICollection <RepositoryReport> model = await repositoryService.GetAnalyzedRepositoriesAsync(p => p.UserId == profile.UserId);

            return(View("_RepositoriesReport", model));
        }
        public async Task <IActionResult> Authenticate()
        {
            int sourceId = await sourceService.GetSourceIdByName(Constants.OAuthSourceNames.GitHubSourceName);

            string accessToken = await httpContextInfoProvider.GetAccessTokenAsync();

            var user = new UserRegisterModel
            {
                UserName    = httpContextInfoProvider.GetUsername(),
                AvatarUrl   = httpContextInfoProvider.GetAvatarUrl(),
                Url         = httpContextInfoProvider.GetExternalUrl(),
                ExternalId  = httpContextInfoProvider.GetExternalId(),
                AccessToken = accessToken,
                SourceId    = sourceId
            };

            return(RedirectToAction("GitHubLogin", "Account", user));
        }
Пример #3
0
        public async Task <IActionResult> Profile()
        {
            string sourceName = httpContextInfoProvider.GetSourceName();
            int    externalId = httpContextInfoProvider.GetExternalId();

            int sourceId = await sourceService.GetSourceIdByName(sourceName);

            int userId = await profileService.GetUserIdByExternalIdAsync(sourceId, externalId);

            UserDTO user = await userService.GetUserByIdAsync(userId);

            //countermeasures if user closed our site on profile registration form
            if (user == null)
            {
                return(RedirectToAction("SignOut"));
            }

            return(View(user));
        }