/*--------------------------------------------------------------------------------------------*/ 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()); }
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(); }
/*--------------------------------------------------------------------------------------------*/ 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()); }
/*--------------------------------------------------------------------------------------------*/ 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 ExecuteScope() { var op = new OauthLoginPostOperation(); return(op.ExecuteScope(OpCtx, vTasks, vClientId, vRedirUri, vAllowScope)); }
/*--------------------------------------------------------------------------------------------*/ private OauthLoginResult ExecuteLogin() { var op = new OauthLoginPostOperation(); return(op.ExecuteLogin(OpCtx, vTasks, vClientId, vRedirUri, vUsername, vPassword)); }