Пример #1
0
        public async Task <IActionResult> Authorize(AuthorizeAddressModel model)
        {
            App app;

            try
            {
                app = (await _apiService.AppInfoAsync(model.appid)).App;
            }
            catch (AiurUnexceptedResponse)
            {
                return(NotFound());
            }
            if (!ModelState.IsValid)
            {
                return(View("AuthError"));
            }
            var url  = new Uri(model.redirect_uri);
            var user = await GetCurrentUserAsync();

            // Wrong domain
            if (url.Host != app.AppDomain && app.DebugMode == false)
            {
                ModelState.AddModelError(string.Empty, "Redirect uri did not work in the valid domain!");
                _logger.LogInformation($"A request with appId {model.appid} is access wrong domian.");
                return(View("AuthError"));
            }
            // Signed in. App is not in force input password mode. User did not specify force input.
            else if (user != null && app.ForceInputPassword != true && model.forceConfirm != true)
            {
                return(await FinishAuth(model.Convert(user.Email), app.ForceConfirmation));
            }
            // Not signed in but we don't want his info
            else if (model.tryAutho == true)
            {
                return(Redirect($"{url.Scheme}://{url.Host}:{url.Port}/?{Values.DirectShowString.Key}={Values.DirectShowString.Value}"));
            }
            var viewModel = new AuthorizeViewModel(model.redirect_uri, model.state, model.appid, model.scope, model.response_type, app.AppName, app.AppIconAddress);

            return(View(viewModel));
        }
Пример #2
0
        //http://localhost:62631/oauth/authorize?appid=29bf5250a6d93d47b6164ac2821d5009&redirect_uri=http%3A%2F%2Flocalhost%3A55771%2FAuth%2FAuthResult&response_type=code&scope=snsapi_base&state=http%3A%2F%2Flocalhost%3A55771%2FAuth%2FGoAuth#aiursoft_redirect
        public async Task <IActionResult> Authorize(AuthorizeAddressModel model)
        {
            var capp = await APIService.AppInfoAsync(model.appid);

            var url = new Uri(model.redirect_uri);

            if (url.Host != capp.AppDomain && capp.DebugMode == false)
            {
                ModelState.AddModelError(string.Empty, "Redirect uri did not work in the valid domain!");
                return(View());
            }
            var cuser = await GetCurrentUserAsync();

            if (cuser != null && capp.ForceInputPassword == false && model.ForceSignInLocally == false)
            {
                return(await FinishAuth(model.Convert(cuser.Email), capp.ForceConfirmation));
            }
            if (ModelState.IsValid)
            {
                var viewModel = new AuthorizeViewModel(model.redirect_uri, model.state, model.appid, model.scope, model.response_type, capp.AppName, capp.AppImageUrl);
                return(View(viewModel));
            }
            return(View());
        }