]> git.openstreetmap.org Git - rails.git/commitdiff
Tidy up the OAuth authorization screens
authorTom Hughes <tom@compton.nu>
Sat, 30 Nov 2013 12:16:44 +0000 (12:16 +0000)
committerTom Hughes <tom@compton.nu>
Sat, 30 Nov 2013 12:25:22 +0000 (12:25 +0000)
Make sure all messages are translatable, separate errors from
user initiated denial of authorization.

app/controllers/oauth_controller.rb
app/views/oauth/authorize.html.erb
app/views/oauth/authorize_failure.html.erb
app/views/oauth/authorize_success.html.erb
config/locales/en.yml
test/integration/oauth_test.rb

index 856fdd79032869d88c6497e2068cec58fb5811c2..7ae7938c37c1e74d288cabdd590ae6da74ebe41d 100644 (file)
@@ -67,10 +67,12 @@ protected
           end
         else
           @token.invalidate!
           end
         else
           @token.invalidate!
+          @message = t("oauth.oauthorize_failure.denied", :app_name => @token.client_application.name)
           render :action => "authorize_failure"
         end
       end
     else
           render :action => "authorize_failure"
         end
       end
     else
+      @message = t "oauth.oauthorize_failure.invalid"
       render :action => "authorize_failure"
     end
   end
       render :action => "authorize_failure"
     end
   end
index 31729d4f03dc8cad6f4bb87705158c4fe20a51a3..d8feeed26d23ad12718584c16110bc294ca49dbc 100644 (file)
@@ -1,8 +1,9 @@
 <% content_for :heading do %>
 <% content_for :heading do %>
-  <h1>Authorize access to your account</h1>
-  <p><%= raw t('oauth.oauthorize.request_access', :app_name => link_to(@token.client_application.name, @token.client_application.url), :user => link_to(@user.display_name, :controller => :user, :action => :view, :display_name => @user.display_name)) %></p>
+  <h1><%= t "oauth.oauthorize.title" %></h1>
 <% end %>
 
 <% end %>
 
+<p><%= raw t("oauth.oauthorize.request_access", :app_name => link_to(@token.client_application.name, @token.client_application.url), :user => link_to(@user.display_name, :controller => :user, :action => :view, :display_name => @user.display_name)) %></p>
+
 <%= form_tag authorize_url do %>
   <%= hidden_field_tag "oauth_token", @token.token %>
   <%- if params[:oauth_callback] -%>
 <%= form_tag authorize_url do %>
   <%= hidden_field_tag "oauth_token", @token.token %>
   <%- if params[:oauth_callback] -%>
index d5e53e4c4d1307f39090c8ca5e3ca57f73d0de85..4afba70e306c685a268286e4823f7fdd80243422 100644 (file)
@@ -1,3 +1,5 @@
 <% content_for :heading do %>
 <% content_for :heading do %>
-  <h1>You have disallowed this request</h1>
-<% end %>
\ No newline at end of file
+  <h1><%= t "oauth.oauthorize_failure.title" %></h1>
+<% end %>
+
+<p><%= @message %></p>
index aa2a52f66579cc2376f6c03da96f25f11b97990f..c8f56af3345a538da083acba1a2db13fca297269 100644 (file)
@@ -1,7 +1,9 @@
 <% content_for :heading do %>
 <% content_for :heading do %>
-  <h1>You have allowed this request</h1>
+  <h1><%= t "oauth.oauthorize_success.title" %></h1>
 <% end %>
 
 <% end %>
 
+<p><%= raw t("oauth.oauthorize_success.allowed", :app_name => link_to(@token.client_application.name, @token.client_application.url)) %></p>
+
 <% if @token.oob? and not @token.oauth10? %>
 <% if @token.oob? and not @token.oauth10? %>
-<p>The verification code is <%= @token.verifier %></p>
+<p><%= t "oauth.oauthorize_success.verification", :code => @token.verifier %></p>
 <% end %>
 <% end %>
index 9e0bfb00995496afa8297d8f9e197c893502a3e0..43c0c4ad1f7a604436d86931348321b5ec38d62c 100644 (file)
@@ -1500,6 +1500,7 @@ en:
       need_to_see_terms: "Your access to the API is temporarily suspended. Please log-in to the web interface to view the Contributor Terms. You do not need to agree, but you must view them."
   oauth:
     oauthorize:
       need_to_see_terms: "Your access to the API is temporarily suspended. Please log-in to the web interface to view the Contributor Terms. You do not need to agree, but you must view them."
   oauth:
     oauthorize:
+      title: "Authorize access to your account"
       request_access: "The application %{app_name} is requesting access to your account, %{user}. Please check whether you would like the application to have the following capabilities. You may choose as many or as few as you like."
       allow_to: "Allow the client application to:"
       allow_read_prefs:  "read your user preferences."
       request_access: "The application %{app_name} is requesting access to your account, %{user}. Please check whether you would like the application to have the following capabilities. You may choose as many or as few as you like."
       allow_to: "Allow the client application to:"
       allow_read_prefs:  "read your user preferences."
@@ -1509,6 +1510,14 @@ en:
       allow_read_gpx:    "read your private GPS traces."
       allow_write_gpx:   "upload GPS traces."
       allow_write_notes: "modify notes."
       allow_read_gpx:    "read your private GPS traces."
       allow_write_gpx:   "upload GPS traces."
       allow_write_notes: "modify notes."
+    oauthorize_success:
+      title: "Authorization request allowed"
+      allowed: "You have granted application %{app_name} access to your account."
+      verification: "The verification code is %{code}."
+    oauthorize_failure:
+      title: "Authorization request failed"
+      denied: "You have denied application %{app_name} access to your account."
+      invalid: "The authorization token is not valid."
     revoke:
       flash: "You've revoked the token for %{application}"
   oauth_clients:
     revoke:
       flash: "You've revoked the token for %{application}"
   oauth_clients:
index eb4a599bd1f44204ff4f84effe7e968677bea212..fbb947af45199b977954df05628fdb63f11306a1 100644 (file)
@@ -285,7 +285,7 @@ class OAuthTest < ActionDispatch::IntegrationTest
       :allow_read_prefs => true, :allow_write_prefs => true
     assert_response :success
     assert_template "authorize_success"
       :allow_read_prefs => true, :allow_write_prefs => true
     assert_response :success
     assert_template "authorize_success"
-    m = response.body.match("<p>The verification code is ([A-Za-z0-9]+)</p>")
+    m = response.body.match("<p>The verification code is ([A-Za-z0-9]+).</p>")
     assert_not_nil m
     verifier = m[1]
     token.reload
     assert_not_nil m
     verifier = m[1]
     token.reload