Browse Source

fix oauth

Markus-Rost 4 years ago
parent
commit
c42b9e8e24
2 changed files with 4 additions and 3 deletions
  1. 1 1
      dashboard/oauth.js
  2. 3 2
      functions/verify.js

+ 1 - 1
dashboard/oauth.js

@@ -346,7 +346,7 @@ function mediawiki_oauth(res, searchParams) {
 			access_token: body.access_token
 		} ).then( () => {
 			oauthVerify.delete(state);
-			res.writeHead(302, {Location: 'https://' + site[1] + '/wiki/Special:MyPage'});
+			res.writeHead(302, {Location: 'https://' + site[0] + '/index.php?title=Special:MyPage'});
 			return res.end();
 		}, error => {
 			console.log( '- Dashboard: Error while sending the mediawiki token: ' + error );

+ 3 - 2
functions/verify.js

@@ -494,10 +494,11 @@ global.verifyOauthUser = function(state, access_token, settings) {
 		} ),
 		channel.guild.members.fetch(settings.user),
 		( !username ? got.get( settings.wiki + 'rest.php/oauth2/resource/profile', {
-			Authorization: `Bearer ${access_token}`
+			headers: {
+				Authorization: `Bearer ${access_token}`
+			}
 		} ).then( response => {
 			var body = response.body;
-			console.log(body)
 			if ( response.statusCode !== 200 || !body?.username ) {
 				console.log( '- ' + response.statusCode + ': Error while getting the mediawiki profile: ' + ( body?.message || body?.error ) );
 				return;