Skip to content
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

Merged
merged 18 commits into from
Nov 4, 2016
Merged

Github username taken #1865

merged 18 commits into from
Nov 4, 2016

Conversation

jykae
Copy link
Contributor

@jykae jykae commented Nov 2, 2016

Closes #1864

@jykae
Copy link
Contributor Author

jykae commented Nov 2, 2016

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) {
Copy link
Contributor

@brylie brylie Nov 3, 2016

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 introduce Meteor.userId()?
    • E.g. keep the code consistent by using only one Meteor.method()
  • storing the user object, or undefined, in a temporary variable might also reduce the noise here
    • only use Meteor.. once
    • only one function call
  • Meteor.user() should return null if user is not logged in

Copy link
Contributor Author

@jykae jykae Nov 3, 2016

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.

@brylie
Copy link
Contributor

brylie commented Nov 3, 2016

This is a nice improvement, and is generally very readable. 😎

@marla-singer
Copy link
Contributor

@jykae Form allows me update profile without username
joxi_screenshot_1478162282813

@brylie brylie assigned marla-singer and unassigned brylie Nov 3, 2016
@marla-singer
Copy link
Contributor

marla-singer commented Nov 3, 2016

@jykae And can't navigate to Catalog and Add api page via navbar

@brylie
Copy link
Contributor

brylie commented Nov 3, 2016

@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:

why does it keep showing me the profile page:question:

-- confused user 😕

@marla-singer
Copy link
Contributor

@brylie These has sAlert
joxi_screenshot_1478162498656

@brylie
Copy link
Contributor

brylie commented Nov 3, 2016

screenshot_20161103_104457

Ah, I need to set my username, before I can add my "Gift Requests API" 🎁 ❗

-- santa claus 🎅

@marla-singer
Copy link
Contributor

@brylie In PR #1859 I suggest to add popup like we have on Reset password. Maybe create another issue to improve an user usability?

@brylie
Copy link
Contributor

brylie commented Nov 3, 2016

Cool, it looks like this PR is headed in the right direction. ✈️

@jykae
Copy link
Contributor Author

jykae commented Nov 3, 2016

@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.
This PR was basically meant to fix just redirect as route for profile has been changed when we have improved settings, and some cleanup for router code.

If we need rethink usability add new issue.

@marla-singer
Copy link
Contributor

@jykae Okay, put aside popup and user usability. But form allows user to update information with empty value

@jykae
Copy link
Contributor Author

jykae commented Nov 3, 2016

@marla-singer yep, I'm checking that one, good find 👍

@jykae
Copy link
Contributor Author

jykae commented Nov 3, 2016

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

@jykae
Copy link
Contributor Author

jykae commented Nov 3, 2016

Also one other find, username also has different requirements on registration vs. profile form

nayttokuva 2016-11-03 kello 12 57 59

nayttokuva 2016-11-03 kello 12 58 30

@brylie
Copy link
Contributor

brylie commented Nov 3, 2016

Cool. Set optional: false in UserSchema.

@jykae
Copy link
Contributor Author

jykae commented Nov 3, 2016

@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.

@jykae
Copy link
Contributor Author

jykae commented Nov 3, 2016

@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..

@jykae
Copy link
Contributor Author

jykae commented Nov 3, 2016

@marla-singer ready for review

thanks @brylie for bug-catching eyeglasses 8-)

@marla-singer
Copy link
Contributor

@jykae I'll merge both branch on local and test

@marla-singer
Copy link
Contributor

marla-singer commented Nov 3, 2016

@jykae Detected problem and can't understand why.

  1. Close all tab with site
  2. Go to site again

Found from my side when router to site in first time:

  • Empty main page, only navbar
  • After refresh page, it's appeared for logined user
  • After refresh page, it is not so for anonymous user
  • After log in or navigate to Catalog, main page is appeared for anonymous user

Do you have something like this?

@jykae
Copy link
Contributor Author

jykae commented Nov 4, 2016

@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 () {
Copy link
Contributor

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) {
Copy link
Contributor

@brylie brylie Nov 4, 2016

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?

@jykae jykae force-pushed the bugfix/github-username-taken branch from f97c258 to 7e93be9 Compare November 4, 2016 08:42
@jykae jykae force-pushed the bugfix/github-username-taken branch from 2ed2154 to bab0bce Compare November 4, 2016 08:46
@jykae
Copy link
Contributor Author

jykae commented Nov 4, 2016

@brylie Different simplified approach, took away unnecessary complexity, cleaned up, ready for review.

@brylie brylie merged commit 0f1127e into develop Nov 4, 2016
@brylie brylie deleted the bugfix/github-username-taken branch November 4, 2016 10:10
@brylie brylie self-assigned this Nov 4, 2016
@jykae jykae added this to the Sprint 34 milestone Nov 4, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants