Commit Graph

171 Commits

Author SHA1 Message Date
Miroslav Bajtoš a5ac1506e6
Forward options in prepareForTokenInvalidation 2017-03-24 15:01:05 +01:00
phairow 91502db9f1
Fix User.verify to convert uid to string
Applications using MongoDB connectors typically have `user.id`
property of type ObjectID.

This commit fixes the code building the verification URL to
correctly convert the user id value into string.
2017-03-08 16:30:01 +01:00
Miroslav Bajtoš 09b1fce34b Fix creation of verification links
Fix User.prototype.verify to call `querystring.stringify` instead
of concatenating query-string components directly.

In particular, this fixes the bug where `options.redirect` containing
a hash fragment like `#/home?arg1=value1&arg2=value2` produced incorrect
URL, because the `redirect` value was not correctly encoded.
2017-02-09 13:33:57 +01:00
Miroslav Bajtoš 8c76d7fc01 Include link to docs in logoutSessions warning 2017-02-08 09:02:39 +01:00
Miroslav Bajtoš 0cc2b5b8db Fix detection of logoutSessionsOnSensitiveChanges
Modify the code detecting whether logoutSessionsOnSensitiveChanges
is enabled to correctly handle the case when the model is not attached
to any application, as is the case with loopback-component-passport
tests.
2017-01-31 15:53:41 +01:00
Miroslav Bajtoš 05db4337cf Preserve sessions on User.save() making no changes 2017-01-31 14:43:24 +01:00
Ritchie Martori 1dac9ada0b Fix logout to handle no or missing accessToken
Return 401 when the request does not provide any accessToken argument
or the token was not found.

Also simplify the implementation of the `logout` method to make only
a single database call (`deleteById`) instead of `findById` + `delete`.
2017-01-30 10:39:40 +01:00
Benjamin Kroeger 56ad85ae2a Role model: resolves related models by name
Resolve models related to the `Role` model by name instead of class.
2017-01-25 11:02:55 +01:00
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