|
|
|
@ -144,12 +144,6 @@ fastify.register(require('point-of-view'), {
|
|
|
|
|
|
|
|
|
|
// * This is for login user as a simply user *
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const axios = require('axios');
|
|
|
|
|
|
|
|
|
|
const FCM_SERVER_KEY = 'AAAAA66BLaA:APA91bHcmbyiNN8hCL-t-M9oH-u7ZMOl74fcImMM2DQZLgdyY98Wu9XxME-CTPcjpjU6Yy48ouxISrOMb9lpa3PJofh8qciUKMNxV2al-bDvGvPP_VVaH0mrTHzR56hdkGy1Zl-0frDO';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fastify.post("/api/login", {
|
|
|
|
|
schema: {
|
|
|
|
|
description: "This is for Login User",
|
|
|
|
@ -213,30 +207,6 @@ fastify.post("/api/login", {
|
|
|
|
|
var stringToJsonObject = JSON.parse(arrayToString); // convert string to json object
|
|
|
|
|
var c_id = loginObject.user.customerId
|
|
|
|
|
var profilePicture = await ProfilePicture.findOne({ customerId:c_id});
|
|
|
|
|
const registrationToken = loginObject.user.fcmId
|
|
|
|
|
console.log(loginObject.user.fcmId)
|
|
|
|
|
// const registrationToken = 'dvbHdP8zTf6fEuOIJVcuUH:APA91bG_h4c68bqGzPoJCQirDQWuo2v7Oc2FrOpf9B4OYFXWTfVrNO-8qwp78xYHzDg9LKvEfWbkLr5B4Nl7w-QIvMjdqxcaQySwx4P1lOxe8tJmf3o2WTQ-vFDbzjnW4_8OP4WIqKXv'; // Retrieve device token from loginObject or database
|
|
|
|
|
const title = 'Login Successful';
|
|
|
|
|
const body = 'Welcome to our app!';
|
|
|
|
|
|
|
|
|
|
const notification = {
|
|
|
|
|
title: title,
|
|
|
|
|
body: body
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const data = {
|
|
|
|
|
to: registrationToken,
|
|
|
|
|
notification: notification
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const headers = {
|
|
|
|
|
'Authorization': `key=${FCM_SERVER_KEY}`,
|
|
|
|
|
'Content-Type': 'application/json'
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const response = await axios.post('https://fcm.googleapis.com/fcm/send', data, { headers });
|
|
|
|
|
|
|
|
|
|
console.log('FCM response:', response.data);
|
|
|
|
|
if (!profilePicture) {
|
|
|
|
|
reply.send({
|
|
|
|
|
simplydata: {
|
|
|
|
|