Skip to content

Comments

Feature/whitelist#59

Open
ysiad wants to merge 69 commits intoAgileVentures:developfrom
junyu-w:feature/whitelist
Open

Feature/whitelist#59
ysiad wants to merge 69 commits intoAgileVentures:developfrom
junyu-w:feature/whitelist

Conversation

@ysiad
Copy link

@ysiad ysiad commented Nov 4, 2016

  1. Add feature tests for white list functionality
  2. Change the privilege of whitelist users that all whitelist users are able to add users and delete users
  3. Change the whitelist to hold GitHub usernames instead of emails

@@ -0,0 +1,28 @@
class Users::ConfirmationsController < Devise::ConfirmationsController
Copy link
Contributor

Choose a reason for hiding this comment

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

this entire file was deleted in develop

Copy link
Author

Choose a reason for hiding this comment

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

Deleted.

@@ -0,0 +1,32 @@
class Users::PasswordsController < Devise::PasswordsController
# GET /resource/password/new
# def new
Copy link
Contributor

Choose a reason for hiding this comment

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

this file was deleted on develop too

Copy link
Author

Choose a reason for hiding this comment

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

Deleted.

# before_action :configure_sign_up_params, only: [:create]
# before_action :configure_account_update_params, only: [:update]

# GET /resource/sign_up
Copy link
Contributor

Choose a reason for hiding this comment

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

same for this one... :)

Copy link
Author

Choose a reason for hiding this comment

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

Deleted

# before_action :configure_sign_in_params, only: [:create]

# GET /resource/sign_in
# def new
Copy link
Contributor

Choose a reason for hiding this comment

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

and this

Copy link
Author

Choose a reason for hiding this comment

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

Deleted.

# super
# end

# POST /resource/unlock
Copy link
Contributor

Choose a reason for hiding this comment

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

deleted

Copy link
Author

Choose a reason for hiding this comment

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

Deleted. Don't know why those files didn't get automatically deleted..

validates_format_of :username,:with => /\A[a-z0-9\-_]+\z/i

def self.has_username?(username)
if Whitelist.find_by_username(username).nil?
Copy link
Contributor

Choose a reason for hiding this comment

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

the function body can be rewritten as !Whitelist.find_by_username(username).nil?

Copy link
Author

Choose a reason for hiding this comment

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

Fixed.

t.timestamps null: false
end

<<<<<<< HEAD
Copy link
Contributor

Choose a reason for hiding this comment

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

merge conflict left-over?

Copy link
Author

Choose a reason for hiding this comment

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

Fixed.

redirect_to whitelists_path
end

def check_if_in_whitelist
Copy link
Contributor

Choose a reason for hiding this comment

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

are we allowing anyone to edit whitelist or only admin?

Copy link
Author

Choose a reason for hiding this comment

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

By the time our professor said, he meant for everyone in the whitelist. Still it's easy for us to change the privilege settings, however we might need to consider redesign the user model so that the privileges can be easily modified.

'/users/sign_in'
when /^the whitelist page/ then
'/whitelists'
when /^the add user to whitelist page/ then
Copy link
Contributor

Choose a reason for hiding this comment

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

the whitelist management page ?

Copy link
Author

Choose a reason for hiding this comment

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

fixed.

Then I should see "User is deleted successfully."
And I should not see "test-admin"

Scenario: Whitelist user delete himself from the whitelist
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the behavior should be if the user deleted himself from whitelist then he should be signed out immediately? or actually we shouldn't allow this self-deleting behavior?

Copy link
Author

Choose a reason for hiding this comment

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

I tested on my local machine. It get redirected to the projects page, and after you click on log out, you will not be able to login again. My best guess for this is that we might need to add another privilege check on projects page so that the user can get signed out immediately. Before each deletion there will be a pop out alert, so the chance of fat finger is actually lowered.

Copy link
Contributor

Choose a reason for hiding this comment

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

instead of adding a check on projects page, we can just delete the user's session right away when he deletes himself?

@junyu-w
Copy link
Contributor

junyu-w commented Nov 4, 2016

@ysiad merge conflicts needs to be resolved

@tansaku
Copy link
Contributor

tansaku commented Nov 16, 2016

I'll try to review this tomorrow - apologies for the delay

def destroy
user = Whitelist.find(params[:id])
if user.username.eql?(current_user.provider_username)
flash[:notice] = "We just saved you from being an idiot. "
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe some more explanation about idiocy here?

@@ -0,0 +1,11 @@
class CreateAuthorizedUser < ActiveRecord::Migration
Copy link
Contributor

Choose a reason for hiding this comment

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

we generally try and avoid manipulating data in our migrations - maybe put this in seed file?

https://robots.thoughtbot.com/data-migrations-in-rails

@@ -0,0 +1,70 @@
@omniauth
Copy link
Contributor

Choose a reason for hiding this comment

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

some inconsistent indenting, and the scenarios are rather imperative - any chance we could evolve them towards a more declarative stance?

also the feature description should tell us why someone wants this feature e.g.

As a projectscope admin
So that I can restrict app access to certain people
I would like to have a whitelist of users who can access the app and restrict everyone else

@tansaku
Copy link
Contributor

tansaku commented Nov 18, 2016

apologies for delay - please see comments embedded

@tansaku
Copy link
Contributor

tansaku commented Nov 22, 2016

thanks @ysiad - can you address codeclimate issues?

@tansaku
Copy link
Contributor

tansaku commented Dec 6, 2016

thanks @ysiad - we still seem to have some failing tests and codeclimate issues - do you need help interpreting them?

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.

4 participants