👔 add create account in provision

Add logic to create a new account when provisioning if not yet registered.
This commit is contained in:
Rafi Arrafif
2025-08-30 22:41:42 +07:00
parent 28d2ddad31
commit bf35af294e
5 changed files with 49 additions and 21 deletions

View File

@ -0,0 +1,22 @@
import { ErrorForwarder } from "../../../../helpers/error/instances/forwarder";
import { hashPassword } from "../../../../helpers/security/password/hash";
import { createUserViaRegisterRepository } from "../../repositories/create/createUserViaRegister.repository";
import {
createUserViaOauth,
createUserViaRegisterInput,
} from "../../user.types";
export const createUserService = async (
payload: createUserViaRegisterInput | createUserViaOauth
) => {
try {
const hashedPassword = await hashPassword(payload.password);
return await createUserViaRegisterRepository({
...payload,
password: hashedPassword,
});
} catch (error) {
ErrorForwarder(error);
}
};

View File

@ -15,3 +15,15 @@ export interface createUserViaRegisterInput {
email: string;
password: string;
}
export interface createUserViaOauth {
provider: string;
providerId: string;
providerToken?: string;
providerPayload?: unknown;
email: string;
username: string;
name: string;
avatar?: string;
bio?: string;
password: string;
}