Пример #1
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());
        }
        /*--------------------------------------------------------------------------------------------*/
        private OauthLoginResult ExecuteLogin()
        {
            var op = new OauthLoginPostOperation();

            return(op.ExecuteLogin(OpCtx, vTasks, vClientId, vRedirUri, vUsername, vPassword));
        }
Пример #3
0
 /*--------------------------------------------------------------------------------------------*/
 private void DoExecuteLogin()
 {
     vExecuteResult = vOper.ExecuteLogin(vMockOpCtx.Object, vMockTasks.Object,
                                         vClientId, vRedirUri, vUsername, vPassword);
 }