Skip to content

Commit

Permalink
Add real password to user
Browse files Browse the repository at this point in the history
  • Loading branch information
RStankov committed Jul 2, 2017
1 parent 02caba2 commit eb0d888
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .rubocop.yml
@@ -1,7 +1,7 @@
AllCops:
Exclude:
- bin/**/*
- db/schema.rb
- db/**/*

# Disables "Line is too long"
LineLength:
Expand Down
1 change: 1 addition & 0 deletions Gemfile
Expand Up @@ -5,6 +5,7 @@ git_source(:github) do |repo_name|
"https://github.com/#{repo_name}.git"
end

gem 'bcrypt'
gem 'puma', '~> 3.7'
gem 'rails', '~> 5.1.0'
gem 'sqlite3'
Expand Down
72 changes: 37 additions & 35 deletions Gemfile.lock
@@ -1,39 +1,39 @@
GEM
remote: https://rubygems.org/
specs:
actioncable (5.1.1)
actionpack (= 5.1.1)
actioncable (5.1.2)
actionpack (= 5.1.2)
nio4r (~> 2.0)
websocket-driver (~> 0.6.1)
actionmailer (5.1.1)
actionpack (= 5.1.1)
actionview (= 5.1.1)
activejob (= 5.1.1)
actionmailer (5.1.2)
actionpack (= 5.1.2)
actionview (= 5.1.2)
activejob (= 5.1.2)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (5.1.1)
actionview (= 5.1.1)
activesupport (= 5.1.1)
actionpack (5.1.2)
actionview (= 5.1.2)
activesupport (= 5.1.2)
rack (~> 2.0)
rack-test (~> 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (5.1.1)
activesupport (= 5.1.1)
actionview (5.1.2)
activesupport (= 5.1.2)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.0.3)
activejob (5.1.1)
activesupport (= 5.1.1)
activejob (5.1.2)
activesupport (= 5.1.2)
globalid (>= 0.3.6)
activemodel (5.1.1)
activesupport (= 5.1.1)
activerecord (5.1.1)
activemodel (= 5.1.1)
activesupport (= 5.1.1)
activemodel (5.1.2)
activesupport (= 5.1.2)
activerecord (5.1.2)
activemodel (= 5.1.2)
activesupport (= 5.1.2)
arel (~> 8.0)
activesupport (5.1.1)
activesupport (5.1.2)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (~> 0.7)
minitest (~> 5.1)
Expand All @@ -42,11 +42,12 @@ GEM
public_suffix (~> 2.0, >= 2.0.2)
arel (8.0.0)
ast (2.3.0)
bcrypt (3.1.11)
bindex (0.5.0)
builder (3.2.3)
byebug (9.0.6)
concurrent-ruby (1.0.5)
erubi (1.6.0)
erubi (1.6.1)
factory_girl (4.8.0)
activesupport (>= 3.0.0)
factory_girl_rails (4.8.0)
Expand Down Expand Up @@ -87,33 +88,33 @@ GEM
rack (2.0.3)
rack-test (0.6.3)
rack (>= 1.0)
rails (5.1.1)
actioncable (= 5.1.1)
actionmailer (= 5.1.1)
actionpack (= 5.1.1)
actionview (= 5.1.1)
activejob (= 5.1.1)
activemodel (= 5.1.1)
activerecord (= 5.1.1)
activesupport (= 5.1.1)
rails (5.1.2)
actioncable (= 5.1.2)
actionmailer (= 5.1.2)
actionpack (= 5.1.2)
actionview (= 5.1.2)
activejob (= 5.1.2)
activemodel (= 5.1.2)
activerecord (= 5.1.2)
activesupport (= 5.1.2)
bundler (>= 1.3.0, < 2.0)
railties (= 5.1.1)
railties (= 5.1.2)
sprockets-rails (>= 2.0.0)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.0.3)
loofah (~> 2.0)
railties (5.1.1)
actionpack (= 5.1.1)
activesupport (= 5.1.1)
railties (5.1.2)
actionpack (= 5.1.2)
activesupport (= 5.1.2)
method_source
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rainbow (2.2.2)
rake
rake (12.0.0)
rb-fsevent (0.9.8)
rb-fsevent (0.10.2)
rb-inotify (0.9.10)
ffi (>= 0.5.0, < 2)
rubocop (0.49.1)
Expand All @@ -123,7 +124,7 @@ GEM
rainbow (>= 1.99.1, < 3.0)
ruby-progressbar (~> 1.7)
unicode-display_width (~> 1.0, >= 1.0.1)
rubocop-rails (0.4.0)
rubocop-rails (0.4.1)
rubocop (~> 0.49)
ruby-progressbar (1.8.1)
ruby_dep (1.5.0)
Expand Down Expand Up @@ -165,6 +166,7 @@ PLATFORMS
ruby

DEPENDENCIES
bcrypt
byebug
factory_girl_rails
graphiql-rails
Expand Down
3 changes: 2 additions & 1 deletion app/graphql/resolvers/create_user.rb
Expand Up @@ -13,7 +13,8 @@ class Resolvers::CreateUser < GraphQL::Function
def call(_obj, args, _ctx)
User.create!(
name: args[:name],
email: args[:authProvider]&.[](:email)&.[](:email)
email: args[:authProvider]&.[](:email)&.[](:email),
password: args[:authProvider]&.[](:email)&.[](:password)
)
rescue ActiveRecord::RecordInvalid => e
GraphQL::ExecutionError.new("Invalid input: #{e.record.errors.full_messages.join(', ')}")
Expand Down
2 changes: 2 additions & 0 deletions app/models/user.rb
@@ -1,4 +1,6 @@
class User < ActiveRecord::Base
has_secure_password

has_many :links, dependent: :destroy
has_many :votes, dependent: :destroy

Expand Down
1 change: 1 addition & 0 deletions db/migrate/20170621145055_create_users_links_and_votes.rb
Expand Up @@ -3,6 +3,7 @@ def change
create_table :users do |t|
t.string :name, null: false
t.string :email, null: false
t.string :password_digest, null: false
t.index :email, unique: true
t.timestamps
end
Expand Down
1 change: 1 addition & 0 deletions db/schema.rb
Expand Up @@ -24,6 +24,7 @@
create_table "users", force: :cascade do |t|
t.string "name", null: false
t.string "email", null: false
t.string "password_digest", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["email"], name: "index_users_on_email", unique: true
Expand Down
1 change: 1 addition & 0 deletions test/factories/users.rb
Expand Up @@ -2,5 +2,6 @@
factory :user do
sequence(:name) { |i| "User #{i}" }
sequence(:email) { |i| "user#{i}@example.com" }
password { '123456' }
end
end

0 comments on commit eb0d888

Please sign in to comment.