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