• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

tulibraries / tul_cob / b4e13125-3ed4-4c2a-ac8e-b545381656c9

06 Sep 2023 01:26PM UTC coverage: 84.602% (-0.2%) from 84.83%
b4e13125-3ed4-4c2a-ac8e-b545381656c9

push

circleci

web-flow
Update rails for security fix (#3932)

* Update rails for security fix

* Add Gemfile.lock

2967 of 3507 relevant lines covered (84.6%)

54.97 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

60.98
/app/models/user.rb
1
# frozen_string_literal: true
2

3
class User < ApplicationRecord
1✔
4
  # Connects this user object to Blacklights Bookmarks.
5
  include Blacklight::User
1✔
6
  include JsonLogger
1✔
7

8
  # Include default devise modules. Others available are:
9
  # :confirmable, :lockable, :timeoutable and :omniauthable
10
  devise :database_authenticatable, :omniauthable, omniauth_providers: [:shibboleth, :saml]
1✔
11

12
  def alma
1✔
13
    log = { type: "alma_user", uid: uid }
×
14
    @alma ||= do_with_json_logger(log) { Alma::User.find(uid) }
×
15
  end
16

17
  # Method added by Blacklight; Blacklight uses #to_s on your
18
  # user class to get a user-displayable login/identifier for
19
  # the account.
20

21
  def to_s
1✔
22
    email
×
23
  end
24

25
  def loans
1✔
26
    log = { type: "alma_loan", uid: uid, order_by: "due_date" }
×
27
    do_with_json_logger(log) { Alma::Loan.where_user(uid, order_by: "due_date") }
×
28
  end
29

30
  def fines
1✔
31
    log = { type: "alma_fines", uid: uid }
×
32
    do_with_json_logger(log) { Alma::Fine.where_user(uid) }
×
33
  end
34

35
  def holds
1✔
36
    log = { type: "alma_holds", uid: uid }
×
37
    do_with_json_logger(log) { Alma::UserRequest.where_user(uid) }
×
38
  end
39

40
  def renew_selected(ids)
1✔
41
    log = { type: "alma_renewal_requests", uid: uid, loan_ids: ids }
×
42
    do_with_json_logger(log) { Alma::User.send_multiple_loan_renewal_requests(user_id: uid, loan_ids: ids) }
×
43
  end
44

45
  def self.from_omniauth(auth)
1✔
46
    email = auth.info.email || "#{auth.uid}@temple.edu"
2✔
47
    where(email: email, uid: auth.uid).first_or_create do |user|
2✔
48
      user.uid        = auth.uid
2✔
49
      user.provider   = auth.provider
2✔
50
      user.email      = email
2✔
51
      user.name       = auth.info.name
2✔
52
      user.last_name  = auth.info.last_name
2✔
53
      user.first_name = auth.info.first_name
2✔
54
    end
55
  end
56

57
  def self.new_with_session(params, session)
1✔
58
    super.tap do |user|
×
59
      if data = session["devise.alma_data"] && session["devise.alma_data"]["extra"]["raw_info"]
×
60
        user.uid = data["uid"] if user.uid.blank?
×
61
      end
62
    end
63
  end
64

65
  def can_purchase_order?
1✔
66
    {
×
67
      "Undergraduate" => "2",
68
      "Graduate/Professional" => "3",
69
      "Faculty/Admin" => "4",
70
      "Emeritus Faculty" =>  "6",
71
      "Law Faculty" => "16",
72
      "Law General" => "17",
73
      "Library Staff" => "22",
74
      "Faculty/Admin-Japan" => "21",
75
      "HSL Student" => "19",
76
    }.values.include? alma.user_group["value"] rescue false
×
77
  end
78

79
  def bookmarks
1✔
80
    (b = super).where!(document_type: "SolrDocument") and b
417✔
81
  end
82

83
  def can_pay_online?
1✔
84
    alma.total_fines > 0
15✔
85
  end
86
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc