Exemple #1
0
        /*--------------------------------------------------------------------------------------------*/
        private static IApiResponse PostLoginCancel(IApiRequest pApiReq)
        {
            Action <IApiResponse> getResp = (apiResp => {
                var o = new OauthLoginPostOperation();
                o.ExecuteCancel(new OauthLoginTasks());
            });

            var exec = new CustomExecutor(pApiReq, getResp, OnLoginException);

            return(exec.Execute());
        }
Exemple #2
0
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        private static IApiResponse GetLogin(IApiRequest pApiReq)
        {
            string incomingError = pApiReq.GetQueryValue("error", false);

            if (incomingError != null)
            {
                string errDesc = pApiReq.GetQueryValue("error_description", false);

                return(new ApiResponse {
                    Html = new LoginErrorView(incomingError, errDesc).ToHtml()
                });
            }

            ////

            Action <IApiResponse> getResp = (apiResp => {
                string respType = pApiReq.GetQueryValue(LoginResponseTypeParam, false);
                string clientId = pApiReq.GetQueryValue(LoginClientIdParam, false);
                string redirUri = pApiReq.GetQueryValue(LoginRedirectUriParam, false);
                string switchMode = pApiReq.GetQueryValue(LoginSwitchModeParam, false);

                var op = new OauthLoginGetOperation();
                OauthLoginResult result = op.Execute(pApiReq.OpCtx, new OauthLoginTasks(),
                                                     clientId, redirUri, respType, switchMode);

                if (result.ShowLoginPage)
                {
                    apiResp.Html = new LoginPageView(result).ToHtml();
                    return;
                }

                if (result.Code != null)
                {
                    apiResp.RedirectUrl = BuildRedirectUri(result.Redirect, result.Code,
                                                           pApiReq.GetQueryValue(LoginStateParam, false));
                    return;
                }

                apiResp.Html = new LoginScopeView(result).ToHtml();
            });

            var exec = new CustomExecutor(pApiReq, getResp, OnLoginException);

            return(exec.Execute());
        }
Exemple #3
0
        /*--------------------------------------------------------------------------------------------*/
        private static IApiResponse PostLoginScope(IApiRequest pApiReq, bool pAllow)
        {
            Action <IApiResponse> getResp = (apiResp => {
                string client = pApiReq.GetQueryValue(LoginClientIdParam, false);
                string redirUri = pApiReq.GetQueryValue(LoginRedirectUriParam, false);

                var op = new OauthLoginPostOperation();
                OauthLoginResult result = op.ExecuteScope(pApiReq.OpCtx, new OauthLoginTasks(),
                                                          client, redirUri, pAllow);

                apiResp.RedirectUrl = BuildRedirectUri(result.Redirect, result.Code,
                                                       pApiReq.GetQueryValue(LoginStateParam, false));
            });

            var exec = new CustomExecutor(pApiReq, getResp, OnLoginException);

            return(exec.Execute());
        }
Exemple #4
0
        /*--------------------------------------------------------------------------------------------*/
        private static IApiResponse PostLoginLogin(IApiRequest pApiReq)
        {
            Action <IApiResponse> getResp = (apiResp => {
                string user = pApiReq.GetFormValue(LoginUsername, true);
                string pass = pApiReq.GetFormValue(LoginPassword, true);
                bool rem = (pApiReq.GetFormValue(LoginRememberMe, false) == "1");

                string clientId = pApiReq.GetQueryValue(LoginClientIdParam, false);
                string redirUri = pApiReq.GetQueryValue(LoginRedirectUriParam, false);

                var op = new OauthLoginPostOperation();
                OauthLoginResult result = op.ExecuteLogin(pApiReq.OpCtx, new OauthLoginTasks(),
                                                          clientId, redirUri, user, pass);

                if (result.ShowLoginPage)
                {
                    apiResp.Html = new LoginPageView(result).ToHtml();
                    return;
                }

                if (result.Code != null)
                {
                    apiResp.RedirectUrl = BuildRedirectUri(result.Redirect, result.Code,
                                                           pApiReq.GetQueryValue(LoginStateParam, false));
                }
                else
                {
                    apiResp.Html = new LoginScopeView(result).ToHtml();
                }

                apiResp.SetUserCookie(result.LoggedUserId, rem);
            });

            var exec = new CustomExecutor(pApiReq, getResp, OnLoginException);

            return(exec.Execute());
        }