fix:direct login
This commit is contained in:
@@ -7,11 +7,13 @@ import { IconsService } from "./providers/icons.service";
|
||||
import { RestaurantService } from "./providers/restaurant.service";
|
||||
import { dmenuConfig } from "../../configs/icons.config";
|
||||
import { SubscriptionsModule } from "../subscriptions/subscriptions.module";
|
||||
import { UsersModule } from "../users/users.module";
|
||||
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
forwardRef(() => SubscriptionsModule),
|
||||
UsersModule
|
||||
],
|
||||
controllers: [DmenuController],
|
||||
providers: [
|
||||
|
||||
@@ -12,6 +12,7 @@ import { UpdateRestaurantDto } from "../DTO/update-restaurant.dto";
|
||||
import { CreateMyRestaurantAdminDto } from "../DTO/create-restaurant-admin.dto";
|
||||
import { PlanEnum, ISetupRestaurant, IExternalApiResponse } from "../interface/plan.interface";
|
||||
import { SubscriptionsService } from "../../subscriptions/providers/subscriptions.service";
|
||||
import { UsersService } from "../../users/providers/users.service";
|
||||
import { SubscriptionMessage } from "../../../common/enums/message.enum";
|
||||
|
||||
|
||||
@@ -23,6 +24,7 @@ export class RestaurantService {
|
||||
@Inject(DMENU_CONFIG) private readonly config: IDmenuConfig,
|
||||
private readonly httpService: HttpService,
|
||||
private readonly subscriptionService: SubscriptionsService,
|
||||
private readonly usersService: UsersService,
|
||||
) { }
|
||||
|
||||
private getHeaders(): Record<string, string> {
|
||||
@@ -435,17 +437,19 @@ export class RestaurantService {
|
||||
async directLogin(userSubscriptionId: string, userId: string) {
|
||||
try {
|
||||
// 1. Get userSubscription by id
|
||||
const { userSubscription } = await this.subscriptionService.getUserSubscriptionById(userSubscriptionId, userId);
|
||||
const user = await this.usersService.findOneById(userId)
|
||||
|
||||
if (!user) {
|
||||
throw new BadRequestException("User Not found");
|
||||
}
|
||||
// 2. Get phone from userSubscription
|
||||
const phone = userSubscription.businessPhone;
|
||||
const phone = user.user.phone
|
||||
if (!phone) {
|
||||
throw new BadRequestException("Phone number not found in user subscription");
|
||||
}
|
||||
|
||||
// 3. Get restaurant by subscription id
|
||||
const restaurant = await this.getRestaurantSubscription(userSubscriptionId);
|
||||
console.log('restaurant', restaurant);
|
||||
|
||||
// 4. Get slug from restaurant
|
||||
const slug = restaurant.data.slug;
|
||||
|
||||
Reference in New Issue
Block a user