コード例 #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());
        }
コード例 #2
0
        public void SetUp()
        {
            vMockData = new Mock <IOperationData>(MockBehavior.Strict);

            vMockOpCtx = new Mock <IOperationContext>(MockBehavior.Strict);
            vMockOpCtx.SetupGet(x => x.Data).Returns(vMockData.Object);

            vMockTasks = new Mock <IOauthLoginTasks>(MockBehavior.Strict);

            vClientId   = "12345";
            vRedirUri   = "http://redirect.to.this.com/test";
            vUsername   = "******";
            vPassword   = "******";
            vAllowScope = true;
            vOper       = new OauthLoginPostOperation();
        }
コード例 #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());
        }
コード例 #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());
        }
コード例 #5
0
        /*--------------------------------------------------------------------------------------------*/
        private OauthLoginResult ExecuteScope()
        {
            var op = new OauthLoginPostOperation();

            return(op.ExecuteScope(OpCtx, vTasks, vClientId, vRedirUri, vAllowScope));
        }
コード例 #6
0
        /*--------------------------------------------------------------------------------------------*/
        private OauthLoginResult ExecuteLogin()
        {
            var op = new OauthLoginPostOperation();

            return(op.ExecuteLogin(OpCtx, vTasks, vClientId, vRedirUri, vUsername, vPassword));
        }