mirror of
https://github.com/PretendoNetwork/account.git
synced 2026-05-27 18:42:39 -05:00
Removed pre-save from PNID
This commit is contained in:
parent
992ba062b9
commit
27a78270cc
|
|
@ -224,24 +224,6 @@ PNIDSchema.methods.getServerMode = function () {
|
|||
return serverMode;
|
||||
};
|
||||
|
||||
PNIDSchema.pre('save', async function(next) {
|
||||
if (!this.isModified('password')) {
|
||||
return next();
|
||||
}
|
||||
|
||||
this.set('usernameLower', this.get('username').toLowerCase());
|
||||
//await this.generatePID();
|
||||
await this.generateEmailValidationCode();
|
||||
await this.generateEmailValidationToken();
|
||||
await this.generateMiiImages();
|
||||
|
||||
const primaryHash = util.nintendoPasswordHash(this.get('password'), this.get('pid'));
|
||||
const hash = bcrypt.hashSync(primaryHash, 10);
|
||||
|
||||
this.set('password', hash);
|
||||
next();
|
||||
});
|
||||
|
||||
const PNID = model('PNID', PNIDSchema);
|
||||
|
||||
module.exports = {
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ const fs = require('fs-extra');
|
|||
const moment = require('moment');
|
||||
const crypto = require('crypto');
|
||||
const hcaptcha = require('hcaptcha');
|
||||
const bcrypt = require('bcrypt');
|
||||
const { PNID } = require('../../../../models/pnid');
|
||||
const { NEXAccount } = require('../../../../models/nex-account');
|
||||
const database = require('../../../../database');
|
||||
|
|
@ -253,12 +254,16 @@ router.post('/', async (request, response) => {
|
|||
|
||||
nexAccount = nexAccountResult[0];
|
||||
|
||||
const primaryPasswordHash = util.nintendoPasswordHash(password, nexAccount.get('pid'));
|
||||
const passwordHash = await bcrypt.hash(primaryPasswordHash, 10);
|
||||
|
||||
const pnidResult = await PNID.create([{
|
||||
pid: nexAccount.get('pid'),
|
||||
creation_date: creationDate,
|
||||
updated: creationDate,
|
||||
username: username,
|
||||
password: password, // will be hashed before saving
|
||||
usernameLower: username.toLowerCase(),
|
||||
password: passwordHash,
|
||||
birthdate: '1990-01-01', // TODO: Change this
|
||||
gender: 'M', // TODO: Change this
|
||||
country: 'US', // TODO: Change this
|
||||
|
|
@ -298,6 +303,10 @@ router.post('/', async (request, response) => {
|
|||
|
||||
pnid = pnidResult[0];
|
||||
|
||||
await pnid.generateEmailValidationCode();
|
||||
await pnid.generateEmailValidationToken();
|
||||
await pnid.generateMiiImages();
|
||||
|
||||
// Quick hack to get the PIDs to match
|
||||
// TODO: Change this
|
||||
// NN with a NNID will always use the NNID PID
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ const router = require('express').Router();
|
|||
const xmlbuilder = require('xmlbuilder');
|
||||
const moment = require('moment');
|
||||
const crypto = require('crypto');
|
||||
const bcrypt = require('bcrypt');
|
||||
const { PNID } = require('../../../models/pnid');
|
||||
const { NEXAccount } = require('../../../models/nex-account');
|
||||
const deviceCertificateMiddleware = require('../../../middleware/device-certificate');
|
||||
|
|
@ -90,12 +91,16 @@ router.post('/', ratelimit, deviceCertificateMiddleware, async (request, respons
|
|||
|
||||
nexAccount = nexAccountResult[0];
|
||||
|
||||
const primaryPasswordHash = util.nintendoPasswordHash(person.get('password'), nexAccount.get('pid'));
|
||||
const passwordHash = await bcrypt.hash(primaryPasswordHash, 10);
|
||||
|
||||
const pnidResult = await PNID.create([{
|
||||
pid: nexAccount.get('pid'),
|
||||
creation_date: creationDate,
|
||||
updated: creationDate,
|
||||
username: person.get('user_id'),
|
||||
password: person.get('password'), // will be hashed before saving
|
||||
usernameLower: person.get('user_id').toLowerCase(),
|
||||
password: passwordHash,
|
||||
birthdate: person.get('birth_date'),
|
||||
gender: person.get('gender'),
|
||||
country: person.get('country'),
|
||||
|
|
@ -135,6 +140,10 @@ router.post('/', ratelimit, deviceCertificateMiddleware, async (request, respons
|
|||
|
||||
pnid = pnidResult[0];
|
||||
|
||||
await pnid.generateEmailValidationCode();
|
||||
await pnid.generateEmailValidationToken();
|
||||
await pnid.generateMiiImages();
|
||||
|
||||
// Quick hack to get the PIDs to match
|
||||
// TODO: Change this
|
||||
// NN with a NNID will always use the NNID PID
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user