Commit Graph

163 Commits

Author SHA1 Message Date
Aris Kemper 5e7e7ca7e9 Fix User methods to use correct Primary Key
Do not use hard-coded "id" property name, call `idName()` to get the
name of the PK property.
2017-01-23 09:51:41 +01:00
Miroslav Bajtoš f1e31ca50c Add app setting logoutSessionsOnSensitiveChanges
Disable invalidation of access tokens by default to restore backwards
compatibility with older 2.x versions.

Add a new application-wide flag logoutSessionsOnSensitiveChanges
that can be used to explicitly turn on/off the token invalidation.

When the flag is not set, a verbose warning is printed to nudge the user
to make a decision how they want to handle token invalidation.
2017-01-20 12:57:23 +01:00
João Ribeiro b8f9b85609 Fix User.resetPassword to call createAccessToken()
This allows User subclasses to override the algorithm used for building
one-time access tokens for password recovery.
2017-01-20 10:59:46 +01:00
Miroslav Bajtoš afd6dd7073 Preserve current session when invalidating tokens
Fix User model to preserve the current session (provided via
"options.accessToken") when invalidating access tokens after a change
of email or password property.
2017-01-16 11:02:29 +01:00
Sergey Reus 5233dcb557 Emit resetPasswordRequest event with options 2017-01-05 15:36:01 +01:00
박대선 659e9ce09b Fix false emailVerified on user model update
We noticed that every time the user model updates, the emailVerified
column would change to false, even though the email was not changed
at all.

I took a look and realized there might be an error in
https://github.com/strongloop/loopback/commit/eb640d8

The intent of the commit just mention is to make emailVerified false
when the email gets changed, but notice that ctx.data.email is null
on updates, so the condition is always met and emailVerified always
becomes false.

This commit fixes the issue just mentioned.
2017-01-05 11:08:35 +01:00
Miroslav Bajtoš 4ee086dcd0 Invalidate AccessTokens on password change
Invalidate all existing sessions (delete all access tokens)
after user's password was changed.
2016-12-12 13:58:20 +01:00
Miroslav Bajtoš 01b2faf14a Fix registration of operation hooks in User model
Operation hooks are inherited by subclassed models, therefore they must
be registered outside of `Model.setup()` function.

This commit fixes this problem in the built-in User model.

There are not tests verifying this change, as writing a test would be
too cumbersome and not worth the cost IMO.
2016-12-09 14:21:38 +01:00
Miroslav Bajtoš 4d41c67c54 Remove "options.template" from Email payload
Fix User.confirm to exclude "options.template" when sending the
confirmation email. Certain nodemailer transport plugins are rejecting
such requests.
2016-12-07 10:54:17 +01:00
Bram Borggreve e7831f6c4d
Allow password reset request for users in realms 2016-11-30 16:57:59 -05:00
Eric a4a96eb39f Add "returnOnlyRoleNames" option to Role.getRoles
Currently the return type of Role.getRoles() method is inconsistent:
role names are returned for smart roles and role ids are returned for
static roles (configured through user-role mapping).

This commit adds a new option to Role.getRoles() allowing the caller
to request role names to be returned for all types of roles.
2016-11-30 17:10:41 +01:00
codyolsen d99d608876 Fix context within listByPrincipalType role method
- Fix for current implimentation that returned all models that had any
  assigned roles. Context was not carried into listByPrincipalType,
  setting roleId as null.
2016-11-15 16:27:56 +01:00
Adrien Kiren 5c1558f969 Add templateFn option to User#verify() 2016-11-15 13:46:35 +01:00
Loay 67e5c6ec1e Require verification after email change
When the User model is configured to require email verification,
then any change of the email address should trigger re-verification.
2016-11-09 11:51:37 -05:00
Dhaval Trivedi 6e880137e4 adding check of string for case insensitive emails 2016-11-04 10:35:08 -04:00
Simon Ho 3e0fd94f60 Need index on principalId for performance. (#2883) (#2884)
Backport of #2883
2016-10-21 16:31:33 -07:00
Miroslav Bajtoš b3497c6778 Allow tokens with eternal TTL (value -1)
- Add a new User setting 'allowEternalTokens'
 - Enhance 'AccessToken.validate' to support eternal tokens with ttl
   value -1 when the user model allows it.
2016-10-12 12:30:33 +02:00
Loay bdeaf654fa Validate non-email property partial update 2016-10-03 16:53:36 -04:00
Loay 59eeb99803 Allow resetPassword if email is verified 2016-09-20 11:29:56 -04:00
Loay e10dcf7c2c Merge pull request #2759 from strongloop/backport/invalidate-email-sessions
Backport/invalidate email sessions
2016-09-20 09:48:16 -04:00
Simon Ho f7f448d569 Add docs for KeyValue model
Backport of #2743
2016-09-19 15:39:01 -07:00
Loay fa310d5882 Invalidate sessions after email change 2016-09-19 14:55:23 -04:00
Miroslav Bajtoš 3df5b2814c Fix double-slash in confirmation URL
Fix the code building the URL used in the email-verification email
to prevent double-slash in the URL when e.g. restApiRoot is '/'.

Before:

  http://example.com//users/confirm?...

Now:

  http://example.com/users/confirm?...
2016-09-12 17:12:24 +02:00
Miroslav Bajtoš 381222bf7a Rework email validation to use isemail
Drop hand-crafted RegExp in favour of a 3rd-party module that supports
RFC5321, RFC5322 and other relevant standards.
2016-09-06 13:00:27 +02:00
Candy 069d3e8f2f Apply g.f to literal strings
Backport #2684
2016-08-29 10:40:36 -04:00
Benjamin Kroeger ecd881a0f3 streamline use if `self` 2016-08-25 10:39:44 +02:00
Benjamin Kroeger c538aa764d resolve related models from correct registry
Also modify setup of test servers when ACL was used, force the app
to `loadBuiltinModels` with localRegistry.
2016-08-25 10:39:44 +02:00
Miroslav Bajtoš b221af7cf6 KeyValueModel: add API for listing keys
- Expose "keys()" at "GET /keys"
 - Add a dummy implementation for "iterateKeys" to serve a useful error
   message when the model is not attached correctly.
2016-08-18 13:34:29 +02:00
Miroslav Bajtoš 7932d75c44 Revert globalization of Swagger descriptions 2016-08-16 14:02:41 +02:00
Amir Jafarian e562137807 Expose `Replace*` methods
*Re-mapping `updateAttributes` endpoint to use
`PATCH` and `PUT`(configurable) verb
*Exposing `replaceById` and `replaceOrCreate` via
`POST` and `PUT`(configurable) verb
2016-08-15 12:17:36 -04:00
Loay d8aa6bdf00 Add bcrypt validation
https://github.com/strongloop/loopback/pull/2580
2016-08-15 09:55:23 -04:00
Miroslav Bajtoš 99dc1f9541 common: add KeyValueModel 2016-08-10 15:30:15 +02:00
Candy 3767940472 Backport of #2407 2016-08-05 11:55:32 -04:00
Miroslav Bajtoš fea3b781a0 Update dependencies to their latest versions 2016-08-05 10:54:42 +02:00
Miroslav Bajtoš 895629632f test: use local registry in test fixtures
Use local registry in test fixtures to prevent collision in globally
shared models.

Fix issues discoverd in auth implementation where the global registry
was used instead of the correct local one.
2016-07-27 15:06:32 +02:00
Loay 619372e51e Backport/Fix security issue 580 2016-07-25 11:06:19 -04:00
Jue Hou 8fe77b2a06 Fix description for User.prototype.hasPassword 2016-06-17 17:35:28 -04:00
Loay 4480cd92ab Fix verificationToken bug #2440 2016-06-17 11:16:06 -04:00
Simon Ho 14aed2251c Merge pull request #2317 from strongloop/backport/change-all-hrefs-in-verification-email
Update user.js
2016-05-10 17:15:23 -07:00
juehou 8fef4845f8 Resolver support return promise 2016-05-10 18:00:42 -04:00
Rik 7868803711 Update user.js
allow to change all {href} instances in user.verify() mail into generated url instead of just one
2016-05-09 12:32:05 -07:00
Supasate Choochaisri 4798b2f8c9 Add feature to not allow duplicate role name
- Also fix jshint error in backported test
2016-05-05 10:51:28 -07:00
Ryan Graham 4d6f2e7ab7
update/insert copyright notices 2016-05-03 17:10:46 -07:00
Miroslav Bajtoš cae9786f0e Fix role.isOwner to support app-local registry 2016-05-03 14:39:29 +02:00
Jue Hou 7a54da5870 Promisify Model Change
* Change.diff
* Change.findOrCreateChange
* Change.rectifyModelChanges
* Change.prototype.currentRevision
* Change.prototype.rectify
2016-02-04 16:01:45 -05:00
Miroslav Bajtoš a0a1083564 Hide verificationToken
We should never be showing this publically.

Adds unit test for hiding verification token.

This is a back-port of pull request #1851 from gausie/patch-4
2016-02-04 16:27:03 +01:00
Amir Jafarian 8deec2e89a Checkpoint speedup 2016-01-19 10:28:53 -05:00
Miroslav Bajtoš 1b765922c9 Merge pull request #1860 from strongloop/fix/replication-performance
Fix replication performance
2015-12-08 19:32:57 +01:00
Miroslav Bajtoš 62d2b0bf0d change: skip cp lookup on no change
Modify `Change.rectify` to look up the current checkpoint only when
there was actually some change made.

This should improve the performance of `rectifyAll` when called from a
regular timer and there were no changes made since the last call.
Before this commit, `rectifyAll` would perform N calls of
`Checkpoint.current` where N is the number of model instances. With
this commit in place, no call is made.
2015-12-08 17:54:26 +01:00
Miroslav Bajtoš 6d040a98ae Merge pull request #1804 from richardpringle/master
Add case-sensitive email option for User model
2015-12-08 12:47:58 +01:00