-
Notifications
You must be signed in to change notification settings - Fork 0
/
helpers.js
33 lines (30 loc) · 948 Bytes
/
helpers.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
'use strict';
const httpntlm = require('httpntlm');
const chalk = require('chalk');
var Spinner = require('cli-spinner').Spinner;
var spinner = new Spinner(chalk.yellow('authenticating... %s'));
spinner.setSpinnerString(Math.floor(Math.random() * 20 + 1));
module.exports = {
authenticateUser: ({ username, password }) => {
return new Promise((resolve, reject) => {
spinner.start();
httpntlm.get(
{
username,
password,
url: 'https://cms.guc.edu.eg/apps/student/HomePageStn.aspx',
rejectUnauthorized: false,
},
(err, res) => {
spinner.stop(true);
console.log(
res.statusCode === 200
? chalk.greenBright('[+] You are authorized')
: chalk.redBright('[!] You are not authorized. Please review your login credentials.')
);
resolve(res.statusCode === 200);
}
);
});
}
}