|
@@ -22,9 +22,9 @@ export class MemberController {
|
|
|
this.userService = new UserService(app)
|
|
this.userService = new UserService(app)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- async createGuest(request: FastifyRequest<{ Querystring: { code?: string } }>, reply: FastifyReply) {
|
|
|
|
|
|
|
+ async createGuest(request: FastifyRequest<{ Querystring: { code?: string; ref?: string } }>, reply: FastifyReply) {
|
|
|
try {
|
|
try {
|
|
|
- const { code } = request.query || {}
|
|
|
|
|
|
|
+ const { code, ref } = request.query || {}
|
|
|
|
|
|
|
|
const ip =
|
|
const ip =
|
|
|
request.ip ||
|
|
request.ip ||
|
|
@@ -32,9 +32,14 @@ export class MemberController {
|
|
|
(request.headers['x-real-ip'] as string) ||
|
|
(request.headers['x-real-ip'] as string) ||
|
|
|
'unknown'
|
|
'unknown'
|
|
|
|
|
|
|
|
- const origin = request.headers.origin || undefined
|
|
|
|
|
|
|
+ let domain = undefined
|
|
|
|
|
+ if (ref) {
|
|
|
|
|
+ domain = ref
|
|
|
|
|
+ } else {
|
|
|
|
|
+ domain = request.headers.origin
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- const user = await this.memberService.createGuest(code, origin, ip)
|
|
|
|
|
|
|
+ const user = await this.memberService.createGuest(code, domain, ip)
|
|
|
const token = await reply.jwtSign({ id: user.id, name: user.name, role: user.role })
|
|
const token = await reply.jwtSign({ id: user.id, name: user.name, role: user.role })
|
|
|
|
|
|
|
|
return reply.code(201).send({
|
|
return reply.code(201).send({
|