Skip to content

Commit

Permalink
SIKKA-6202[IN PROGRESS]
Browse files Browse the repository at this point in the history
  • Loading branch information
Mansourkira committed Jan 6, 2024
1 parent 4db24dc commit 0db4f3a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sikka/hajar",
"version": "1.1.43",
"version": "1.1.44",
"description": "Toolkit to create SaaS applications",
"author": "Sikka Software <contact@sikka.io> (http://sikka.io)",
"license": "MIT",
Expand Down
13 changes: 8 additions & 5 deletions src/core/authentication/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,19 +235,23 @@ class HajarAuth {
email: googleUserData.email,
ref: "customers",
});

if (!user) {
user = new this.User({
username: googleUserData.username,
email: googleUserData.email,
ref: "customers",
password: await this.bcrypt.hash(googleUserData.password, 10),
// role: googleUserData.role,
// role: googleUserData.role,
});

await user.save();
}
const customerData = await this.Customer.findOne({ profile: user._id });

let customerData = await this.Customer.findOne({ uid: user._id });

if (!customerData) {
const customer = new this.Customer({
customerData = new this.Customer({
profile: user._id,
// role: googleUserData.role,
uid: user._id,
Expand All @@ -256,7 +260,7 @@ class HajarAuth {
lastName: googleUserData.lastName,
});

await customer.save();
await customerData.save();
}

return {
Expand All @@ -267,7 +271,6 @@ class HajarAuth {
token: this.jwt.sign({ userId: user._id }, this.secret),
};
}

user = await this.User.findOne({
email: googleUserData.email,
ref: "customers",
Expand Down

0 comments on commit 0db4f3a

Please sign in to comment.