profile service
This commit is contained in:
parent
42fea55233
commit
ec725f8e4e
4 changed files with 16 additions and 18 deletions
|
|
@ -148,7 +148,6 @@ class ApiRoutesProvider {
|
|||
});
|
||||
}
|
||||
if (error instanceof this.errors.ForbiddenError) {
|
||||
console.log('helo?1');
|
||||
return res.status(403).json({
|
||||
success: false,
|
||||
message: 'This public key is not authorized.',
|
||||
|
|
@ -160,8 +159,7 @@ class ApiRoutesProvider {
|
|||
message: 'Unexpected error.',
|
||||
});
|
||||
}
|
||||
console.log('helo?2');
|
||||
console.log(completedLoginChallenge);
|
||||
|
||||
await this.services.sessionService.relateSessionToPublicKey(
|
||||
sessionUuid,
|
||||
completedLoginChallenge.public_key
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ class ServicesProvider {
|
|||
}).provide();
|
||||
|
||||
const ProfileServiceProvider = require('../services/profileService');
|
||||
const profileService = new ProfileServiceProvider().provide();
|
||||
const profileService = new ProfileServiceProvider({ models }).provide();
|
||||
const OfferServiceProvider = require('../services/offerService');
|
||||
const offerService = new OfferServiceProvider().provide();
|
||||
|
||||
|
|
|
|||
|
|
@ -39,7 +39,6 @@ class LoginServiceProvider {
|
|||
completedNostrChallenge.public_key
|
||||
))
|
||||
) {
|
||||
console.log('helo4');
|
||||
throw new this.errors.ForbiddenError(
|
||||
`Public key ${completedNostrChallenge.public_key} is not authorized.`
|
||||
);
|
||||
|
|
@ -53,9 +52,6 @@ class LoginServiceProvider {
|
|||
created_at: new Date().toISOString(),
|
||||
});
|
||||
|
||||
console.log('helo3');
|
||||
console.log(completedLoginChallenge);
|
||||
|
||||
return completedLoginChallenge;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -3,37 +3,41 @@ const uuid = require('uuid');
|
|||
const models = require('../models');
|
||||
|
||||
class ProfileServiceProvider {
|
||||
constructor({ models }) {
|
||||
this.models = models;
|
||||
}
|
||||
provide() {
|
||||
async function setContactDetails(publicKey, encryptedContactDetails) {
|
||||
return await models.ContactDetailsSet.create({
|
||||
const setContactDetails = async (publicKey, encryptedContactDetails) => {
|
||||
return await this.models.ContactDetailsSet.create({
|
||||
uuid: uuid.v7(),
|
||||
public_key: publicKey,
|
||||
encrypted_contact_details: encryptedContactDetails,
|
||||
created_at: new Date().toISOString(),
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
async function setNym(publicKey, nym) {
|
||||
return await models.NymSet.create({
|
||||
const setNym = async (publicKey, nym) => {
|
||||
return await this.models.NymSet.create({
|
||||
uuid: uuid.v7(),
|
||||
public_key: publicKey,
|
||||
nym: nym,
|
||||
created_at: new Date().toISOString(),
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
async function areProfileDetailsComplete(publicKey) {
|
||||
const isNymSet = await models.NymSet.findOne({
|
||||
const areProfileDetailsComplete = async (publicKey) => {
|
||||
console.log(this.models);
|
||||
const isNymSet = await this.models.NymSet.findOne({
|
||||
where: { public_key: publicKey },
|
||||
});
|
||||
const areContactDetailsSet = await models.ContactDetailsSet.findOne({
|
||||
const areContactDetailsSet = await this.models.ContactDetailsSet.findOne({
|
||||
where: {
|
||||
public_key: publicKey,
|
||||
},
|
||||
});
|
||||
|
||||
return isNymSet && areContactDetailsSet;
|
||||
}
|
||||
};
|
||||
|
||||
return { setContactDetails, setNym, areProfileDetailsComplete };
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue