mirror of
				https://codeberg.org/yeentown/barkey.git
				synced 2025-11-04 15:34:13 +00:00 
			
		
		
		
	fix: oauth/authorize not working
This commit is contained in:
		
							parent
							
								
									9814fe81b4
								
							
						
					
					
						commit
						c5008452c1
					
				
					 2 changed files with 11 additions and 19 deletions
				
			
		| 
						 | 
				
			
			@ -186,6 +186,17 @@ export class ServerService implements OnApplicationShutdown {
 | 
			
		|||
			}
 | 
			
		||||
		});
 | 
			
		||||
 | 
			
		||||
		fastify.get('/oauth/authorize', async (request, reply) => {
 | 
			
		||||
			const query: any = request.query;
 | 
			
		||||
			let param = "mastodon=true";
 | 
			
		||||
			if (query.state) param += `&state=${query.state}`;
 | 
			
		||||
			if (query.redirect_uri) param += `&redirect_uri=${query.redirect_uri}`;
 | 
			
		||||
			const client = query.client_id ? query.client_id : "";
 | 
			
		||||
			reply.redirect(
 | 
			
		||||
				`${Buffer.from(client.toString(), 'base64').toString()}?${param}`,
 | 
			
		||||
			);
 | 
			
		||||
		});
 | 
			
		||||
 | 
			
		||||
		fastify.get<{ Params: { code: string } }>('/verify-email/:code', async (request, reply) => {
 | 
			
		||||
			const profile = await this.userProfilesRepository.findOneBy({
 | 
			
		||||
				emailVerifyCode: request.params.code,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -67,25 +67,6 @@ export class OAuth2ProviderService {
 | 
			
		|||
			payload.on('error', done);
 | 
			
		||||
		});
 | 
			
		||||
 | 
			
		||||
		fastify.get('/oauth/authorize', async (request, reply) => {
 | 
			
		||||
			const query: any = request.query;
 | 
			
		||||
			let param = "mastodon=true";
 | 
			
		||||
			if (query.state) param += `&state=${query.state}`;
 | 
			
		||||
			if (query.redirect_uri) param += `&redirect_uri=${query.redirect_uri}`;
 | 
			
		||||
			const client = query.client_id ? query.client_id : "";
 | 
			
		||||
			reply.redirect(
 | 
			
		||||
				`${Buffer.from(client.toString(), 'base64').toString()}?${param}`,
 | 
			
		||||
			);
 | 
			
		||||
		});
 | 
			
		||||
 | 
			
		||||
		fastify.post('/oauth/decision', async (request, reply) => {
 | 
			
		||||
			const body: any = request.body;
 | 
			
		||||
			if (body.cancel) {
 | 
			
		||||
				reply.send({ user: body.login_token, allow: false });
 | 
			
		||||
			}
 | 
			
		||||
			reply.send({ user: body.login_token, allow: true });
 | 
			
		||||
		});
 | 
			
		||||
 | 
			
		||||
		fastify.post('/oauth/token', async (request, reply) => {
 | 
			
		||||
			const body: any = request.body || request.query;
 | 
			
		||||
			if (body.grant_type === "client_credentials") {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue