Skip to content

Commit

Permalink
Merge pull request #3 from jsbrn/dev
Browse files Browse the repository at this point in the history
Merge v3 into master
  • Loading branch information
jsbrn authored Jan 27, 2020
2 parents 688ce3d + 1399f02 commit 71561fe
Show file tree
Hide file tree
Showing 21 changed files with 1,365 additions and 525 deletions.
18 changes: 7 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ A handy free service to find a Public Mobile referral code to get the $10 credit
**Features**

* Instantly get a referral to use when signing up for Public Mobile account.
* Register your Public Mobile referral code to get randomly selected when other people request a referral.
* Codes are verified on Public Mobile's website before being accepted into the database.
* If a user closes their PM account, PMReferrals will delete the code the next time someone tries to use it.
* Register your Public Mobile referral code to start collecting anonymous referrals.
* Codes are ranked by a scoring system. Collect points by maintaining activity on the site, and sharing it with others.
* Points are reset each week.
* Codes are automatically verified on registration and login. Removed from the rankings if found to be invalid.

**Contributing**

Expand All @@ -34,18 +35,13 @@ MONGODB_PORT=27017
MONGODB_DATABASE=database_name
MONGODB_SRV_RECORD=false
MOCK_CODE_VALIDATION=false
[email protected]
EMAIL_PASSWORD=password2
SMTP_SERVER=mail.example.com
SMTP_PORT=465
MESSAGE=PMReferrals is down for maintenance.
SUBMESSAGE=Come back in an hour!
MAINTENANCE=false
BASE_URL=https://example.com
```

When `MOCK_CODE_VALIDATION` is true, the codes will always be accepted. Email is not currently used by the application, so don't worry about configuring it. It used to be, in an older version.

**Bug Reports**

If you are using the site and find a problem, please feel free to create a new issue on this repository. It will be super helpful as we try to build a useful tool for everyone.
4 changes: 2 additions & 2 deletions app/database.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ function disconnect() {
});
}

function update(collectionName, query, new_values, onSuccess, onFailure) {
function update(collectionName, query, new_value, onSuccess, onFailure) {
var collection = database.collection(collectionName);
collection.update(query, {$set: new_values}, function(err, docs) {
collection.updateMany(query, {$set: new_value}, function(err, docs) {
if (err) {
console.log(err.message);
onFailure();
Expand Down
10 changes: 6 additions & 4 deletions app/validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,19 @@ function isValidPhone(number) {
return n_patt.test(number) && number.length == 10;
}

function findOnPage(needle, url, callback) {
function verifyCode(code, callback) {

const agent = new https.Agent({
rejectUnauthorized: false
});

axios.get(url, { httpsAgent: agent })
axios.get("https://activate.publicmobile.ca/?raf="+code, { httpsAgent: agent })
.then(function (axios_response) {
//if it has the green checkmark it's a valid code
var broken_page = !axios_response.data.includes("ok_16x16") && !axios_response.data.includes("failure_16x16");
callback({
valid: axios_response.data.includes(needle)
valid: axios_response.data.includes("ok_16x16"),
error: broken_page
})
})
.catch(function (err) {
Expand All @@ -42,4 +44,4 @@ function findOnPage(needle, url, callback) {

module.exports.isValidEmail = isValidEmail;
module.exports.isValidPhone = isValidPhone;
module.exports.findOnPage = findOnPage;
module.exports.verifyCode = verifyCode;
Loading

0 comments on commit 71561fe

Please sign in to comment.