@adminforth/open-signup 1.0.8 → 1.0.9

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/Changelog.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## [v1.0.9]
2
+
3
+ # Fixed
4
+ - when user created normalize email to lowercase. This is not needed when right email validator is set on email field because
5
+ it will not allow to create such email, but if user forgot to set it it might save situation
1
6
 
2
7
  ## [v1.0.8]
3
8
 
@@ -38,7 +38,7 @@
38
38
  <div class="p-4 md:p-5">
39
39
  <form v-if="!requestSent" class="space-y-4" role="alert" @submit.prevent>
40
40
  <div v-if="!verifyToken" class="relative">
41
- <label for="email" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">{{$t('Your email')}}</label>
41
+ <label for="email" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">{{$t('Your email address')}}</label>
42
42
  <input type="email" name="email" id="email"
43
43
  tabindex="1"
44
44
  autocomplete="username"
@@ -50,7 +50,7 @@
50
50
  />
51
51
  </div>
52
52
  <div v-if="isPasswordNeeded" class="relative">
53
- <label for="password" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">{{$t('New password')}}</label>
53
+ <label for="password" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">{{$t('Your password')}}</label>
54
54
  <input
55
55
  tabindex="2"
56
56
  autocomplete="new-password"
@@ -74,7 +74,7 @@
74
74
  </div>
75
75
 
76
76
  <div v-if="isPasswordNeeded" class="relative">
77
- <label for="password_confirmation" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">{{$t('Confirm new password')}}</label>
77
+ <label for="password_confirmation" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">{{$t('Confirm your password')}}</label>
78
78
  <input
79
79
  ref="passwordConfirmationInput"
80
80
  autocomplete="new-password"
@@ -38,7 +38,7 @@
38
38
  <div class="p-4 md:p-5">
39
39
  <form v-if="!requestSent" class="space-y-4" role="alert" @submit.prevent>
40
40
  <div v-if="!verifyToken" class="relative">
41
- <label for="email" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">{{$t('Your email')}}</label>
41
+ <label for="email" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">{{$t('Your email address')}}</label>
42
42
  <input type="email" name="email" id="email"
43
43
  tabindex="1"
44
44
  autocomplete="username"
@@ -50,7 +50,7 @@
50
50
  />
51
51
  </div>
52
52
  <div v-if="isPasswordNeeded" class="relative">
53
- <label for="password" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">{{$t('New password')}}</label>
53
+ <label for="password" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">{{$t('Your password')}}</label>
54
54
  <input
55
55
  tabindex="2"
56
56
  autocomplete="new-password"
@@ -74,7 +74,7 @@
74
74
  </div>
75
75
 
76
76
  <div v-if="isPasswordNeeded" class="relative">
77
- <label for="password_confirmation" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">{{$t('Confirm new password')}}</label>
77
+ <label for="password_confirmation" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">{{$t('Confirm your password')}}</label>
78
78
  <input
79
79
  ref="passwordConfirmationInput"
80
80
  autocomplete="new-password"
package/dist/index.js CHANGED
@@ -198,14 +198,17 @@ export default class OpenSignupPlugin extends AdminForthPlugin {
198
198
  }
199
199
  }
200
200
  }
201
+ // This is not needed when right email validator is set on email field because
202
+ // it will not allow to create such email, but if user forgot to set it it might save situation
203
+ const normalizedEmail = email.toLowerCase(); // normalize email
201
204
  // first check again if email already exists
202
- const existingUser = yield this.adminforth.resource(this.authResource.resourceId).get(Filters.EQ(this.emailField.name, email));
205
+ const existingUser = yield this.adminforth.resource(this.authResource.resourceId).get(Filters.EQ(this.emailField.name, normalizedEmail));
203
206
  if ((!this.options.confirmEmails && existingUser) || (this.options.confirmEmails && (existingUser === null || existingUser === void 0 ? void 0 : existingUser[this.emailConfirmedField.name]))) {
204
207
  return { error: tr('Email already exists', 'opensignup'), ok: false };
205
208
  }
206
209
  // create user
207
210
  if (!existingUser) {
208
- const created = yield this.adminforth.resource(this.authResource.resourceId).create(Object.assign(Object.assign(Object.assign({}, (this.options.defaultFieldValues || {})), (this.options.confirmEmails ? { [this.options.confirmEmails.emailConfirmedField]: false } : {})), { [this.emailField.name]: email, [this.options.passwordHashField]: password ? yield AdminForth.Utils.generatePasswordHash(password) : '' }));
211
+ const created = yield this.adminforth.resource(this.authResource.resourceId).create(Object.assign(Object.assign(Object.assign({}, (this.options.defaultFieldValues || {})), (this.options.confirmEmails ? { [this.options.confirmEmails.emailConfirmedField]: false } : {})), { [this.emailField.name]: normalizedEmail, [this.options.passwordHashField]: password ? yield AdminForth.Utils.generatePasswordHash(password) : '' }));
209
212
  }
210
213
  if (!this.options.confirmEmails) {
211
214
  const resp = yield this.doLogin(email, response, { body, headers, query, cookies });
package/index.ts CHANGED
@@ -227,9 +227,13 @@ export default class OpenSignupPlugin extends AdminForthPlugin {
227
227
  }
228
228
  }
229
229
  }
230
+
231
+ // This is not needed when right email validator is set on email field because
232
+ // it will not allow to create such email, but if user forgot to set it it might save situation
233
+ const normalizedEmail = email.toLowerCase(); // normalize email
230
234
 
231
235
  // first check again if email already exists
232
- const existingUser = await this.adminforth.resource(this.authResource.resourceId).get(Filters.EQ(this.emailField.name, email));
236
+ const existingUser = await this.adminforth.resource(this.authResource.resourceId).get(Filters.EQ(this.emailField.name, normalizedEmail));
233
237
  if ((!this.options.confirmEmails && existingUser) || (this.options.confirmEmails && existingUser?.[this.emailConfirmedField.name])) {
234
238
  return { error: tr('Email already exists', 'opensignup'), ok: false };
235
239
  }
@@ -239,7 +243,7 @@ export default class OpenSignupPlugin extends AdminForthPlugin {
239
243
  const created = await this.adminforth.resource(this.authResource.resourceId).create({
240
244
  ...(this.options.defaultFieldValues || {}),
241
245
  ...(this.options.confirmEmails ? { [this.options.confirmEmails.emailConfirmedField]: false } : {}),
242
- [this.emailField.name]: email,
246
+ [this.emailField.name]: normalizedEmail,
243
247
  [this.options.passwordHashField]: password ? await AdminForth.Utils.generatePasswordHash(password) : '',
244
248
  });
245
249
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/open-signup",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",