@tomei/sso 0.55.0 → 0.56.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/components/login-user/user.d.ts +1 -0
- package/dist/src/components/login-user/user.js +20 -0
- package/dist/src/components/login-user/user.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/migrations/20250108091133-add-passcode-to-user-table.js +1 -1
- package/package.json +1 -1
- package/src/components/login-user/user.ts +40 -0
package/package.json
CHANGED
@@ -2868,4 +2868,44 @@ export class User extends UserBase {
|
|
2868
2868
|
throw error;
|
2869
2869
|
}
|
2870
2870
|
}
|
2871
|
+
|
2872
|
+
async verifyPasscode(passcode: string) {
|
2873
|
+
try {
|
2874
|
+
// Return error if this._Userid is empty "User is not created yet."
|
2875
|
+
if (!this.UserId) {
|
2876
|
+
throw new ClassError(
|
2877
|
+
'User',
|
2878
|
+
'UserErrMsg0X',
|
2879
|
+
'User is not created yet.',
|
2880
|
+
);
|
2881
|
+
}
|
2882
|
+
// Return error if this._PasscodeHash is empty. "Passcode has not been set yet."
|
2883
|
+
if (!this.PasscodeHash) {
|
2884
|
+
throw new ClassError(
|
2885
|
+
'User',
|
2886
|
+
'UserErrMsg0X',
|
2887
|
+
'Passcode has not been set yet.',
|
2888
|
+
'verifyPasscode',
|
2889
|
+
);
|
2890
|
+
}
|
2891
|
+
// Using the same password hash service during create passcode. Validate this._PasscodeHash with params.passcode. Return error if not matched. "Invalid passcode."
|
2892
|
+
const passwordHashService = new PasswordHashService();
|
2893
|
+
const isMatch = await passwordHashService.verify(
|
2894
|
+
passcode,
|
2895
|
+
this.PasscodeHash,
|
2896
|
+
);
|
2897
|
+
|
2898
|
+
if (!isMatch) {
|
2899
|
+
throw new ClassError(
|
2900
|
+
'User',
|
2901
|
+
'UserErrMsg0X',
|
2902
|
+
'Invalid passcode.',
|
2903
|
+
'verifyPasscode',
|
2904
|
+
400,
|
2905
|
+
);
|
2906
|
+
}
|
2907
|
+
} catch (error) {
|
2908
|
+
throw error;
|
2909
|
+
}
|
2910
|
+
}
|
2871
2911
|
}
|