File tree Expand file tree Collapse file tree 3 files changed +3
-24
lines changed
Expand file tree Collapse file tree 3 files changed +3
-24
lines changed Original file line number Diff line number Diff line change @@ -39,12 +39,10 @@ def self.from_omniauth(auth)
3939 db_user = find_by ( zauth_id : auth . uid )
4040
4141 if db_user . nil?
42- db_user = find_or_create_by! ( name : auth . extra . raw_info [ "username" ] ) do |user |
42+ db_user = find_or_create_by! ( zauth_id : auth . uid ) do |user |
4343 user . generate_key!
4444 user . private = true
4545 end
46-
47- db_user . zauth_id = auth . uid
4846 end
4947
5048 # overwrite name (for if name changed)
Original file line number Diff line number Diff line change 2626FactoryBot . define do
2727 factory :user do
2828 name { Faker ::Internet . user_name }
29+ zauth_id { Faker ::String . random }
2930 private { false }
3031
3132 factory :admin do
Original file line number Diff line number Diff line change 8888 let ( :auth_hash ) do
8989 OmniAuth ::AuthHash . new (
9090 {
91- uid : 7 ,
91+ uid : "7" ,
9292 extra : {
9393 raw_info : { roles : [ ] , username : existing_user . name }
9494 }
106106 end
107107 end
108108
109- describe "when the user already exists but without zauth id" do
110- let! ( :existing_user ) { create ( :user ) }
111- let ( :auth_hash ) do
112- OmniAuth ::AuthHash . new (
113- {
114- uid : "7" ,
115- extra : {
116- raw_info : { roles : [ ] , username : existing_user . name }
117- }
118- }
119- )
120- end
121-
122- it "finds the existing user" do
123- user = described_class . from_omniauth ( auth_hash )
124- expect ( user ) . to eq ( existing_user )
125- expect ( user . admin ) . to be ( false )
126- end
127- end
128-
129109 describe "when the user exists but has changed their name" do
130110 let! ( :existing_user ) { create ( :user ) }
131111 let ( :auth_hash ) do
You can’t perform that action at this time.
0 commit comments