MCPcopy Index your code
hub / github.com/bugy/script-server / processCurrentOauthState

Function processCurrentOauthState

web-src/src/login/login.js:130–172  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

128}
129
130function processCurrentOauthState() {
131 var oauthState = restoreState();
132
133 var oauthResponseCode = getQueryParameter(OAUTH_RESPONSE_KEY);
134 var queryStateToken = getQueryParameter('state');
135 if (oauthState || oauthResponseCode) {
136 if (!oauthState && oauthResponseCode) {
137 showError('Invalid client state. Please try to relogin');
138 return;
139 }
140
141 var nextUrl = oauthState[NEXT_URL_KEY];
142 var urlFragment = oauthState['urlFragment'];
143
144 var previousLocation = getUnparameterizedUrl();
145 if (nextUrl) {
146 previousLocation += '?' + toQueryArgs({'next': nextUrl});
147 }
148 if (urlFragment) {
149 previousLocation += urlFragment;
150 }
151
152
153 if (!oauthResponseCode) {
154 if (getQueryParameter(NEXT_URL_KEY)) {
155 return;
156 }
157 window.location = previousLocation;
158 } else {
159 window.history.pushState(null, '', previousLocation);
160 }
161
162 var localStateToken = oauthState.token;
163 if (queryStateToken !== localStateToken) {
164 showError('Invalid client state. Please try to relogin');
165 return;
166 }
167
168 var formData = new FormData();
169 formData.append(OAUTH_RESPONSE_KEY, oauthResponseCode);
170 sendLoginRequest(formData);
171 }
172}
173
174function getLoginButton() {
175 return document.getElementsByClassName('login-button')[0];

Callers 1

setupOAuthFunction · 0.85

Calls 7

getQueryParameterFunction · 0.90
getUnparameterizedUrlFunction · 0.90
toQueryArgsFunction · 0.90
restoreStateFunction · 0.85
showErrorFunction · 0.85
sendLoginRequestFunction · 0.85
appendMethod · 0.80

Tested by

no test coverage detected