import { Controller, Get, Param, Put } from '@nestjs/common';
import { AuthService } from './auth.service.js';

@Controller('auth')
export class AuthController {
  constructor(private readonly authService: AuthService) {}

  @Get()
  getAccessToken(): any {
    return this.authService.getAccessToken();
  }

  @Get('users')
  getUsers(): any {
    return this.authService.getUsers();
  }
  @Get('user/:userid')
  getUser(@Param('userid') userId: string): any {
    return this.authService.getUser(userId);
  }
  @Get('groups')
  getGroups(): any {
    return this.authService.getGroups();
  }

  @Get('user/:userid/groups') //e0811669-c7eb-4e5e-a699-e8334d5c5b01 -> aknuth
  getGroupsForUsers(@Param('userid') userId: string): any {
    return this.authService.getGroupsForUser(userId);
  }

  @Get('user/:userid/lastlogin') //e0811669-c7eb-4e5e-a699-e8334d5c5b01 -> aknuth
  getLastLogin(@Param('userid') userId: string): any {
    return this.authService.getLastLogin(userId);
  }

  @Put('user/:userid/group/:groupid') //e0811669-c7eb-4e5e-a699-e8334d5c5b01 -> aknuth // 
  addUser2Group(@Param('userid') userId: string,@Param('groupid') groupId: string): any {
    return this.authService.addUser2Group(userId,groupId);
  }
}
