feat: support admin api bind address to user (#630)

This commit is contained in:
Dream Hunter
2025-04-12 19:49:59 +08:00
committed by GitHub
parent 47e2cb56b4
commit 0894ac0dc9
4 changed files with 22 additions and 16 deletions
+14 -1
View File
@@ -7,10 +7,16 @@ import { getJsonSetting } from "../utils"
import { CONSTANTS } from "../constants";
import { unbindTelegramByAddress } from '../telegram_api/common';
export default {
const UserBindAddressModule = {
bind: async (c: Context<HonoCustomType>) => {
const { user_id } = c.get("userPayload");
const { address_id } = c.get("jwtPayload");
return await UserBindAddressModule.bindByID(c, user_id, address_id)
},
bindByID: async (
c: Context<HonoCustomType>,
user_id: number | string, address_id: number | string
) => {
if (!address_id || !user_id) {
return c.text("No address or user token", 400)
}
@@ -96,6 +102,11 @@ export default {
},
getBindedAddresses: async (c: Context<HonoCustomType>) => {
const { user_id } = c.get("userPayload");
return await UserBindAddressModule.getBindedAddressesById(c, user_id);
},
getBindedAddressesById: async (
c: Context<HonoCustomType>, user_id: number | string
) => {
if (!user_id) {
return c.text("No user token", 400)
}
@@ -229,3 +240,5 @@ export default {
return c.json({ success: true })
}
}
export default UserBindAddressModule;