Skip to content

Commit

Permalink
fix: remove the creation of an admin in the dashboard app
Browse files Browse the repository at this point in the history
The admin must be created in the Bandada backend.

re #460
  • Loading branch information
vplasencia committed Mar 30, 2024
1 parent 627c9f4 commit fa7cecc
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 55 deletions.
19 changes: 1 addition & 18 deletions apps/api/src/app/admins/admins.controller.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,13 @@
import {
Body,
Controller,
Get,
Param,
Post,
Put,
UseGuards
} from "@nestjs/common"
import { Body, Controller, Get, Param, Put, UseGuards } from "@nestjs/common"
import { ApiExcludeEndpoint } from "@nestjs/swagger"
import { AuthGuard } from "../auth/auth.guard"
import { CreateAdminDTO } from "./dto/create-admin.dto"
import { AdminsService } from "./admins.service"
import { Admin } from "./entities/admin.entity"
import { UpdateApiKeyDTO } from "./dto/update-apikey.dto"

@Controller("admins")
export class AdminsController {
constructor(private readonly adminsService: AdminsService) {}

@Post()
@UseGuards(AuthGuard)
@ApiExcludeEndpoint()
async createAdmin(@Body() dto: CreateAdminDTO): Promise<Admin> {
return this.adminsService.create(dto)
}

@Get(":admin")
@UseGuards(AuthGuard)
@ApiExcludeEndpoint()
Expand Down
25 changes: 0 additions & 25 deletions apps/dashboard/src/api/bandadaAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,31 +108,6 @@ export async function createGroup(
}
}

/**
* It creates a new admin.
* @param id The admin id.
* @param address The admin address.
* @returns The Admin.
*/
export async function createAdmin(
id: string,
address: string
): Promise<Admin | null> {
try {
return await request(`${API_URL}/admins`, {
method: "POST",
data: {
id,
address
}
})
} catch (error: any) {
console.error(error)
createAlert(error.response.data.message)
return null
}
}

/**
* It returns details of a specific admin.
* @param adminId The admin id.
Expand Down
13 changes: 1 addition & 12 deletions apps/dashboard/src/context/auth-context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,7 @@ import { SiweMessage } from "siwe"
import { configureChains, createClient, WagmiConfig } from "wagmi"
import { sepolia } from "wagmi/chains"
import { publicProvider } from "wagmi/providers/public"
import {
createAdmin,
getAdmin,
getNonce,
logOut,
signIn
} from "../api/bandadaAPI"
import { getNonce, logOut, signIn } from "../api/bandadaAPI"
import useSessionData from "../hooks/use-session-data"
import { Admin } from "../types"

Expand Down Expand Up @@ -73,11 +67,6 @@ export function AuthContextProvider({ children }: { children: ReactNode }) {
if (admin) {
saveAdmin(admin)

const alreadyCreated = await getAdmin(admin.id)

if (!alreadyCreated)
await createAdmin(admin.id, admin.address)

return true
}

Expand Down

0 comments on commit fa7cecc

Please sign in to comment.