Secured website post request by password

This commit is contained in:
keplyx 2019-08-26 18:03:01 +02:00
parent 528867ab3c
commit 47d2e4f2c0

View file

@ -4,6 +4,7 @@ import * as Permissions from 'expo-permissions';
import {Notifications} from 'expo'; import {Notifications} from 'expo';
import AsyncStorageManager from "./AsyncStorageManager"; import AsyncStorageManager from "./AsyncStorageManager";
import LocaleManager from "./LocaleManager"; import LocaleManager from "./LocaleManager";
import passwords from "../passwords";
const EXPO_TOKEN_SERVER = 'https://srv-falcon.etud.insa-toulouse.fr/~amicale_app/expo_notifications/save_token.php'; const EXPO_TOKEN_SERVER = 'https://srv-falcon.etud.insa-toulouse.fr/~amicale_app/expo_notifications/save_token.php';
@ -54,10 +55,8 @@ export default class NotificationsManager {
*/ */
static async scheduleNotification(title: string, body: string, time: number, data: Object, androidChannelID: string): Promise<string> { static async scheduleNotification(title: string, body: string, time: number, data: Object, androidChannelID: string): Promise<string> {
await NotificationsManager.askPermissions(); await NotificationsManager.askPermissions();
console.log(time);
let date = new Date(); let date = new Date();
date.setTime(time); date.setTime(time);
console.log(date);
return Notifications.scheduleLocalNotificationAsync( return Notifications.scheduleLocalNotificationAsync(
{ {
title: title, title: title,
@ -116,6 +115,7 @@ export default class NotificationsManager {
} }
let data = { let data = {
function: 'get_machine_watchlist', function: 'get_machine_watchlist',
password: passwords.expoNotifications,
token: token, token: token,
}; };
fetch(EXPO_TOKEN_SERVER, { fetch(EXPO_TOKEN_SERVER, {
@ -148,6 +148,7 @@ export default class NotificationsManager {
} }
let data = { let data = {
function: 'setup_machine_notification', function: 'setup_machine_notification',
password: passwords.expoNotifications,
locale: LocaleManager.getCurrentLocale(), locale: LocaleManager.getCurrentLocale(),
token: token, token: token,
machine_id: machineID, machine_id: machineID,
@ -175,13 +176,13 @@ export default class NotificationsManager {
* @param time * @param time
*/ */
static setMachineReminderNotificationTime(time: number) { static setMachineReminderNotificationTime(time: number) {
console.log(time);
let token = AsyncStorageManager.getInstance().preferences.expoToken.current; let token = AsyncStorageManager.getInstance().preferences.expoToken.current;
if (token === '') { if (token === '') {
throw Error('Expo token not available'); throw Error('Expo token not available');
} }
let data = { let data = {
function: 'set_machine_reminder', function: 'set_machine_reminder',
password: passwords.expoNotifications,
token: token, token: token,
time: time, time: time,
}; };