Skip to content

Commit 39ffd3a

Browse files
committed
check if the zauth id is valid
1 parent 99e2ef6 commit 39ffd3a

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

app/models/user.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ class User < ApplicationRecord
3737
def self.from_omniauth(auth)
3838
zauth_id = auth.extra.raw_info["id"]
3939
unless zauth_id.is_a? Integer
40-
puts "help"
41-
return
40+
raise "zauth id is not valid, this is not good, what is happening? what did you do? i am confused and will give up"
4241
end
4342

4443
db_user = find_by(zauth_id: zauth_id)

spec/models/user_spec.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,23 @@
213213
expect(user.admin).to be(true)
214214
end
215215
end
216+
217+
describe "when the user has an invalid zauth id" do
218+
let(:auth_hash) do
219+
OmniAuth::AuthHash.new(
220+
{
221+
uid: "a-test-user",
222+
extra: {
223+
raw_info: { roles: ["tap_admin"], id: "7" }
224+
}
225+
}
226+
)
227+
end
228+
229+
it "fails" do
230+
expect { described_class.from_omniauth(auth_hash) }.to raise_error("zauth id is not valid, this is not good, what is happening? what did you do? i am confused and will give up")
231+
end
232+
end
216233
end
217234

218235
describe "static users" do

0 commit comments

Comments
 (0)