Conversation
|
works, but I clean it tomorrow |
users/client/lib/router.js
Outdated
| // Redirect to profile page if user doesn't have username | ||
| // Eg. logged in with Github & username already taken | ||
| const redirectToProfile = function () { | ||
| if (Meteor.userId() && !Meteor.user().username) { |
There was a problem hiding this comment.
Would the following work here instead?
if (Meteor.user() && Meteor.user().username !== undefined) {
...
};or, for example:
// Get user, if logged in - otherwise `null`
const user = Meteor.user();
if (user && user.username != undefined) {
...
};- The
!== undefinedis more explicit - since we are already relying on
Meteor.user(), why introduceMeteor.userId()?- E.g. keep the code consistent by using only one
Meteor.method()
- E.g. keep the code consistent by using only one
- storing the
userobject, orundefined, in a temporary variable might also reduce the noise here- only use
Meteor..once - only one function call
- only use
Meteor.user()should returnnullif user is not logged in
There was a problem hiding this comment.
@brylie everything else I agree here but that explicitly saying "!== undefined", it should be common knowledge for JavaScript developer that it checks case "undefined", imho.
|
This is a nice improvement, and is generally very readable. 😎 |
|
@jykae Form allows me update profile without username |
|
@jykae And can't navigate to Catalog and Add api page via navbar |
|
@jykae we should also notify the user why they have been redirected to the profile page, if this is not already happening. Otherwise, it would be confusing:
|
|
@brylie These has sAlert |
|
Cool, it looks like this PR is headed in the right direction. |
|
@marla-singer this logic setting for username if it is already taken has been like this for about year, as it was designed to function like this. If we need rethink usability add new issue. |
|
@jykae Okay, put aside popup and user usability. But form allows user to update information with empty value |
|
@marla-singer yep, I'm checking that one, good find 👍 |
|
Interesting we have separate template for username that does not seem to be included anywhere https://github.com/apinf/platform/tree/develop/users/client/account/username O_o |
|
Cool. Set |
|
@brylie I really hope it would be that simple. That solution provides "Internal server error" already in Github registration/login phase, when trying to create user, as username is required. |
|
@marla-singer now it doesn't allow empty username, but shows "Please set username" 2 times on first redirect to profile. :) I can't see where this bug hides.. |
|
@marla-singer ready for review thanks @brylie for bug-catching eyeglasses 8-) |
|
@jykae I'll merge both branch on local and test |
|
@jykae Detected problem and can't understand why.
Found from my side when router to site in first time:
Do you have something like this? |
|
@marla-singer sorry, moved this.next outside if-statement, what about now? |
users/client/lib/router.js
Outdated
|
|
||
| // Redirect to profile page if user doesn't have username | ||
| // Eg. logged in with Github & username already taken | ||
| const checkUsername = function () { |
There was a problem hiding this comment.
This is an improvement in the function name. However, lets be just slightly more explicit, with something like:
ensureUsernameExistsensureUserHasUsername
Using 'ensure' means that we are 'making sure' the user has a username, and is consistent with the ensureSignedIn function name.
users/client/profile/profile.js
Outdated
| AutoForm.hooks({ | ||
| updateProfile: { | ||
| before: { | ||
| update (user) { |
There was a problem hiding this comment.
Can't we do this easier by making username: { optional: false } in the user profile schema?
f97c258 to
7e93be9
Compare
2ed2154 to
bab0bce
Compare
|
@brylie Different simplified approach, took away unnecessary complexity, cleaned up, ready for review. |





Closes #1864