Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion backend/src/auth/auth.controller.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Controller, Post, Body } from '@nestjs/common';
import { Controller, Post, Body, Get, Req } from '@nestjs/common';
import { AuthService } from './auth.service';
import { CreateAuthDto } from './dto/create-auth.dto';
import { ApiTags } from '@nestjs/swagger';
Expand All @@ -14,4 +14,10 @@ export class AuthController {
create(@Body() createAuthDto: CreateAuthDto) {
return this.authService.createOrLogin(createAuthDto);
}

@Get()
getAuth(@Req() req) {
const userId = req.user.sub;
return this.authService.getAuthUser(userId);
}
}
4 changes: 4 additions & 0 deletions backend/src/auth/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ export class AuthService {
};
}

async getAuthUser(id: string) {
return this.usersService.findOne(id);
}

// Function to validate signature
private async isValidSignature(
address: string,
Expand Down
2 changes: 1 addition & 1 deletion backend/src/common/guards/auth.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class AuthGuard implements CanActivate {
constructor(
private jwtService: JwtService,
private reflector: Reflector,
) { }
) {}

async canActivate(context: ExecutionContext): Promise<boolean> {
const isPublic = this.reflector.getAllAndOverride<boolean>(IS_PUBLIC_KEY, [
Expand Down
2 changes: 1 addition & 1 deletion backend/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ async function bootstrap() {
const document = SwaggerModule.createDocument(app, config);
SwaggerModule.setup('swagger/api', app, document);

app.enableCors();
app.enableCors({});
await app.listen(PORT, () => {
console.log(`Running API in MODE: ${process.env.NODE_ENV} on port ${PORT}`);
});
Expand Down
5 changes: 5 additions & 0 deletions backend/src/users/users.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ export class UsersController {
return this.usersService.findOne(id);
}

@Get(':address')
findByAddress(@Param('address') address: string) {
return this.usersService.findOneByAddress(address);
}

@Delete(':id')
remove(@Param('id') id: string) {
return this.usersService.remove(+id);
Expand Down