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

Notifications field added while creating users with omniauth #3158

Merged
merged 6 commits into from
Aug 2, 2018

Conversation

SidharthBansal
Copy link
Member

@SidharthBansal SidharthBansal commented Jul 26, 2018

Closes #3032

Make sure these boxes are checked before your pull request (PR) is ready to be reviewed and merged. Thanks!

  • tests pass -- look for a green checkbox ✔️ a few minutes after opening your PR -- or run tests locally with rake test
  • code is in uniquely-named feature branch and has no merge conflicts
  • PR is descriptively titled
  • PR body includes fixes #0000-style reference to original issue #
  • ask @publiclab/reviewers for help, in a comment below

We're happy to help you get this ready -- don't be afraid to ask for help, and don't be discouraged if your tests fail at first!

If tests do fail, click on the red X to learn why by reading the logs.

Please be sure you've reviewed our contribution guidelines at https://publiclab.org/contributing-to-public-lab-software

We have a loose schedule of reviewing and pulling in changes every Tuesday and Friday, and publishing changes on Fridays.

Thanks!

@ghost ghost assigned SidharthBansal Jul 26, 2018
@ghost ghost added the in progress label Jul 26, 2018
@plotsbot
Copy link
Collaborator

plotsbot commented Jul 26, 2018

2 Warnings
⚠️ New migrations added. Please update schema.rb.example by overwriting it with a copy of the up-to-date db/schema.rb. Also, be aware to preserve the MySQL-specific conditions for full-text indices.
⚠️ It looks like you merged from master in this pull request. Please rebase to get rid of the merge commits – you may want to rewind the master branch and rebase instead of merging in from master, which can cause problems when accepting new code!
2 Messages
📖 @SidharthBansal Thank you for your pull request! I’m here to help with some tips and recommendations. Please take a look at the list provided and help us review and accept your contribution! And don’t be discouraged if you see errors – we’re here to help.
📖 It looks like you haven’t marked all the checkboxes. Help us review and accept your suggested changes by going through the steps one by one. If it is still a ‘Work in progresss’, please include ‘[WIP]’ in the title.

Generated by 🚫 Danger

@SidharthBansal SidharthBansal added the help wanted requires help by anyone willing to contribute label Jul 26, 2018
@SidharthBansal
Copy link
Member Author

@jywarren we migrated users instead of rusers in #3098. Can you please rollback the db for changes of #3098 before merging this one? Sorry for the inconvenience.

@SidharthBansal
Copy link
Member Author

image

@SidharthBansal SidharthBansal added ready and removed help wanted requires help by anyone willing to contribute in progress labels Jul 31, 2018
@SidharthBansal SidharthBansal added this to the OAuth milestone Jul 31, 2018
@jywarren
Copy link
Member

jywarren commented Jul 31, 2018 via email

@SidharthBansal
Copy link
Member Author

Hi @jywarren I have added the migration for removal of password_checker field in this pr. Can you please review it?

@SidharthBansal
Copy link
Member Author

I think we are getting octokit error again. Maybe it is due to change of key as it happened earlier

@SidharthBansal
Copy link
Member Author

Can we please ignore codeclimate errors? They are for deeply nested if-else.

Copy link
Member

@jywarren jywarren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple small changes! Thanks!!!!

@@ -0,0 +1,5 @@
class AddPasswordCheckerToRusers < ActiveRecord::Migration[5.2]
def change
add_column :rusers, :password_checker, :integer, default: 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These could actually be in the same migration!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I could not understand what I need to change.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are two migrations. First is to delete password_checker from Users.
Second is to add password_checker to RUsers.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh just that you can perform both steps in the same migration file. They needn't be separated... Although it's not a big deal, over the lifetime of the project I think we should try not to have too many migration files. Mind changing this? Thanks!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will change it

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for explanation

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please add link to the code for example? I tried a lot searching on net and on plots2 migration files. We can have different dbms queries on same table in single migration. But I could not find a migration with two different tables involved. In this pr, we are involved with two tables Rusers(removal of password checker) & Users(addition of password checker).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe it'll work to do:

def change
  remove_column :users, :password_checker, :integer
  add_column :rusers, :password_checker, :integer, default: 0
end

I don't have an example but have you tried it? I think the table name is just specified in the one line, no? But honestly it's not a big deal, just a slight preference, so if you find that it doesn't work, 2 files is fine!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot. I was thinking other type of solution which was giving errors.
Thanks it worked.

u = User.find_by(username: username)
if u && u.password_checker != 0
n = u.password_checker
hash = { 1 => "Facebook", 2 => "Github", 3 => "Google", 4 => "Twitter" }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to use the style 1: "Facebook" here?

Copy link
Member Author

@SidharthBansal SidharthBansal Aug 1, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi I tried but it is giving syntax error. I know that we should use colons instead of hash rockets. But this is not working here. I guess, we use colons when we use symbols --> value.
Thanks

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't make integers as symbols as at another place I am using the reverse hash. In reverse hash I am mapping providers with integer values.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok! thanks for trying!

@jywarren
Copy link
Member

jywarren commented Aug 1, 2018

Also where could we helpfully explain the usage of password checker?

@SidharthBansal
Copy link
Member Author

SidharthBansal commented Aug 1, 2018

I have sent the documentation.

@SidharthBansal
Copy link
Member Author

@jywarren can you please review this?
Thanks

@jywarren
Copy link
Member

jywarren commented Aug 1, 2018

This looks good - are you confident that we should merge? Thanks!

@SidharthBansal
Copy link
Member Author

Yes
Thanks

@jywarren jywarren merged commit 010bb27 into publiclab:master Aug 2, 2018
@ghost ghost removed the ready label Aug 2, 2018
stefannibrasil pushed a commit to milaaraujo/plots2 that referenced this pull request Aug 3, 2018
…ab#3158)

* Notifications field added in users

* Rails migration rollback and new migration added

* Migrations corrected

* Added documentation

* Two migrations merged into one
SrinandanPai pushed a commit to SrinandanPai/plots2 that referenced this pull request May 5, 2019
…ab#3158)

* Notifications field added in users

* Rails migration rollback and new migration added

* Migrations corrected

* Added documentation

* Two migrations merged into one
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Password checker field in OAuth Login
3 participants