Skip to content

Commit 1bbe3ea

Browse files
committed
refactor based upon PR feedback
1 parent ae2c353 commit 1bbe3ea

4 files changed

Lines changed: 23 additions & 33 deletions

File tree

app/assets/stylesheets/includes/main.scss

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ header {
9797
}
9898

9999
ul {
100-
a, button.calnet_login {
100+
a, form.calnet_auth > button {
101101
color: black;
102102

103103
&:hover {
@@ -257,24 +257,15 @@ section {
257257
}
258258

259259
&.restricted {
260-
form.auth {
260+
div.access_methods {
261261
margin-right: auto;
262262
margin-bottom: 0.25rem;
263263

264-
div.access_methods {
265-
button.calnet_login {
266-
box-shadow: inset 0 -4px 0 $color-anchor-highlight;
267-
268-
&:hover {
269-
background: $color-anchor-highlight;
270-
}
271-
}
272-
a {
273-
box-shadow: inset 0 -4px 0 $color-anchor-highlight;
264+
a, form.calnet_auth > button {
265+
box-shadow: inset 0 -4px 0 $color-anchor-highlight;
274266

275-
&:hover {
276-
background: $color-anchor-highlight;
277-
}
267+
&:hover {
268+
background: $color-anchor-highlight;
278269
}
279270
}
280271
}
@@ -410,11 +401,13 @@ span {
410401
// sass-lint:enable class-name-format
411402
}
412403

413-
button.calnet_login {
414-
background: inherit;
415-
margin: inherit;
416-
padding: inherit;
417-
border: inherit;
418-
font: inherit;
404+
form.calnet_auth {
419405
display: inline;
406+
button {
407+
background: inherit;
408+
margin: inherit;
409+
padding: inherit;
410+
border: inherit;
411+
font: inherit;
412+
}
420413
}

app/helpers/application_helper.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
module ApplicationHelper
22
def calnet_link
3-
authenticated? ? logout_link : login_link
3+
authenticated? ? logout_link : login_button
44
end
55

66
def logout_link(text = 'CalNet Logout')
77
link_to(text, logout_path)
88
end
99

10-
def login_link(text = 'CalNet Login')
11-
form_tag('/auth/calnet', url: request.original_url, method: 'post', data: { turbo: false }) do
12-
login_button text
13-
end
10+
def calnet_omniauth_authorize_path
11+
'/auth/calnet'
1412
end
1513

16-
def login_button(text = 'CalNet Login')
17-
button_tag text, class: 'calnet_login', role: 'link'
14+
def login_button(text = 'CalNet Login', form_class: 'calnet_auth')
15+
button_to(text, calnet_omniauth_authorize_path,
16+
params: { url: request.original_url },
17+
form_class:, data: { turbo: false })
1818
end
1919

2020
def vpn_link

app/views/player/access_restricted.erb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,19 @@
22
<%
33
calnet_only = record&.calnet_only?
44
access_methods = [].tap do |mm|
5-
mm << login_button('log in with CalNet') unless authenticated?
5+
mm << login_button('log in with CalNet', form_class: 'calnet_auth restricted') unless authenticated?
66
mm << vpn_link unless calnet_only || ucb_request?
77
end
88
%>
99
<section class="record restricted">
1010
<h1>Access to this record is restricted</h1>
1111

12-
<%= form_tag('/auth/calnet', url: request.original_url, method: 'post', data: { turbo: false }, class: 'auth') do %>
1312
<div class="access_methods">
1413
The specified record is available to UC Berkeley users only.
1514
<% unless access_methods.empty? # should never happen %>
1615
For full access, <%= access_methods.join(', or ').html_safe %>.
1716
<% end %>
1817
</div>
19-
<% end %>
2018
2119
<table>
2220
<thead>

spec/support/authz_shared_examples.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@
2727
expect(page).to have_content(collection)
2828
expect(page).to have_content(record_id)
2929

30-
# show_url = player_url(collection:, record_id:)
31-
expect(page).to have_css('button.calnet_login')
30+
expect(page).to have_selector("div.access_methods > form[action='/auth/calnet']")
3231
end
3332
end
3433

0 commit comments

Comments
 (0)