-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Github username taken #1865
Github username taken #1865
Conversation
works, but I clean it tomorrow |
// 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
!== undefined
is 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
user
object, orundefined
, in a temporary variable might also reduce the noise here- only use
Meteor..
once - only one function call
- only use
Meteor.user()
should returnnull
if user is not logged in
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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? |
@@ -35,16 +42,38 @@ Router.route('/settings/profile', { | |||
template: 'profile', | |||
}); | |||
|
|||
// 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an improvement in the function name. However, lets be just slightly more explicit, with something like:
ensureUsernameExists
ensureUserHasUsername
Using 'ensure' means that we are 'making sure' the user has a username, and is consistent with the ensureSignedIn
function name.
@@ -1,5 +1,21 @@ | |||
AutoForm.hooks({ | |||
updateProfile: { | |||
before: { | |||
update (user) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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