Reorganised OAuth clients and tokens details page. Made clients info editable and some more stuff translatable in the OAuth pages.

This commit is contained in:
Matt Amos 2009-08-03 17:08:40 +00:00
parent 7c1cde7035
commit 655dc6787e
9 changed files with 109 additions and 112 deletions

View file

@ -1,40 +1,23 @@
<div class="field"> <div class="field">
<label for="client_application_name">Name*</label><br/> <label for="client_application_name"><%= t'oauth.client_application.form.name' %> (<%= t'oauth.client_application.form.required' %>)</label><br/>
<%= f.text_field :name %> <%= f.text_field :name %>
</div> </div>
<div class="field"> <div class="field">
<label for="client_application_url">Main Application URL*</label><br/> <label for="client_application_url"><%= t'oauth.client_application.form.url' %> (<%= t'oauth.client_application.form.required' %>)</label><br/>
<%= f.text_field :url %> <%= f.text_field :url %>
</div> </div>
<div class="field"> <div class="field">
<label for="client_application_callback_url">Callback URL*</label><br/> <label for="client_application_callback_url"><%= t'oauth.client_application.form.callback_url' %></label><br/>
<%= f.text_field :callback_url %> <%= f.text_field :callback_url %>
</div> </div>
<div class="field"> <div class="field">
<label for="client_application_support_url">Support URL</label><br/> <label for="client_application_support_url"><%= t'oauth.client_application.form.support_url' %></label><br/>
<%= f.text_field :support_url %> <%= f.text_field :support_url %>
</div> </div>
<p><%= t'oauth.client_application.form.requests' %></p>
<% ClientApplication.all_permissions.each do |perm| %>
<div class="field"> <div class="field">
<%= f.check_box :allow_read_prefs %> <%= f.check_box perm %>
<label for="client_application_allow_read_prefs">Request permission to read the user preferences.</label><br/> <label for="client_application_<%= perm.to_s %>"><%= t('oauth.client_application.form.' + perm.to_s) %></label><br/>
</div>
<div class="field">
<%= f.check_box :allow_write_prefs %>
<label for="client_application_allow_write_prefs">Request permission to write the user preferences.</label><br/>
</div>
<div class="field">
<%= f.check_box :allow_write_diary %>
<label for="client_application_allow_write_diary">Request permission to create diary entries, comments and friends.</label><br/>
</div>
<div class="field">
<%= f.check_box :allow_write_api %>
<label for="client_application_allow_write_api">Request permission to write the API on the user's behalf.</label><br/>
</div>
<div class="field">
<%= f.check_box :allow_read_gpx %>
<label for="client_application_allow_read_gpx">Request permission to read the user's private GPS traces.</label><br/>
</div>
<div class="field">
<%= f.check_box :allow_write_gpx %>
<label for="client_application_allow_write_gpx">Request permission to upload GPS traces as the user.</label><br/>
</div> </div>
<% end %>

View file

@ -1,5 +1,6 @@
<h1>Edit your application</h1> <h1><%= t'oauth.client_application.edit.title' %></h1>
<% form_for :client_application do |f| %> <% form_for :client_application, @client_application, :url => oauth_client_path(@client_application), :html => { :method => :put } do |f| %>
<%= render :partial => "form", :locals => { :f => f } %> <%= render :partial => "form", :locals => { :f => f } %>
<%= submit_tag "Edit" %> <br/>
<%= submit_tag t'oauth.client_application.edit.submit' %>
<% end %> <% end %>

View file

@ -1,9 +1,10 @@
<div class="flash"><%= flash[:notice] %></div> <h1><%= t'oauth.client_application.index.title' %></h1>
<h1>OAuth Client Applications</h1>
<% unless @tokens.empty? %> <% unless @tokens.empty? %>
<p>The following tokens have been issued to applications in your name</p> <h3><%= t'oauth.client_application.index.my_tokens' %></h3>
<p><%= t'oauth.client_application.index.list_tokens' %></p>
<table> <table>
<tr><th>Application</th><th>Issued</th><th>&nbsp;</th></tr> <tr><th><%= t'oauth.client_application.index.application' %></th>
<th><%= t'oauth.client_application.index.issued_at' %></th><th>&nbsp;</th></tr>
<% @tokens.each do |token|%> <% @tokens.each do |token|%>
<% content_tag_for :tr, token do %> <% content_tag_for :tr, token do %>
<td><%= link_to token.client_application.name, token.client_application.url %></td> <td><%= link_to token.client_application.name, token.client_application.url %></td>
@ -11,29 +12,22 @@
<td> <td>
<% form_tag :controller => 'oauth', :action => 'revoke' do %> <% form_tag :controller => 'oauth', :action => 'revoke' do %>
<%= hidden_field_tag 'token', token.token %> <%= hidden_field_tag 'token', token.token %>
<%= submit_tag "Revoke!" %> <%= submit_tag t('oauth.client_application.index.revoke') %>
<% end %> <% end %>
</td> </td>
<% end %> <% end %>
<% end %> <% end %>
</table> </table>
<% end %> <% end %>
<h3>Application Developers</h3> <h3><%= t'oauth.client_application.index.my_apps' %></h3>
<% if @client_applications.empty? %> <% if @client_applications.empty? %>
<p> <p><%= t('oauth.client_application.index.no_apps', :oauth => "<a href=\"http://oauth.net\">OAuth</a>") %></p>
Do you have an application you would like to register for use with us using the <a href="http://oauth.net">OAuth</a> standard?
</p>
<p>
You must register your web application before it can make OAuth requests to this service
</p>
<% else %> <% else %>
<p> <p><%= t'oauth.client_application.index.registered_apps' %></p>
You have the following client applications registered:
</p>
<% @client_applications.each do |client|%> <% @client_applications.each do |client|%>
<% div_for client do %> <% div_for client do %>
<%= link_to client.name, :action => :show, :id => client.id %> <%= link_to client.name, :action => :show, :id => client.id %>
<% end %> <% end %>
<% end %> <% end %>
<% end %> <% end %>
<h3><%= link_to "Register your application", :action => :new %></h3> <h3><%= link_to t('oauth.client_application.index.register_new'), :action => :new %></h3>

View file

@ -1,6 +1,6 @@
<h1>Register a new application</h1> <h1><%= t'oauth.client_application.new.title' %></h1>
<% form_for :client_application, :url => { :action => :create } do |f| %> <% form_for :client_application, :url => { :action => :create } do |f| %>
<%= render :partial => "form", :locals => { :f => f } %> <%= render :partial => "form", :locals => { :f => f } %>
<br /> <br />
<%= submit_tag "Register" %> <%= submit_tag t'oauth.client_application.new.submit' %>
<% end %> <% end %>

View file

@ -1,20 +1,28 @@
<h1>OAuth details for <%=@client_application.name %></h1> <h1><%= t('oauth.client_application.show.title', :app_name => @client_application.name) %></h1>
<p> <p>
<b>Consumer Key:</b> <%=@client_application.key %> <b><%= t'oauth.client_application.show.key' %></b> <%=@client_application.key %>
</p> </p>
<p> <p>
<b>Consumer Secret:</b> <%=@client_application.secret %> <b><%= t'oauth.client_application.show.secret' %></b> <%=@client_application.secret %>
</p> </p>
<p> <p>
<b>Request Token URL</b> http<%='s' if request.ssl? %>://<%= request.host_with_port %><%=@client_application.oauth_server.request_token_path %> <b><%= t'oauth.client_application.show.url' %></b> http<%='s' if request.ssl? %>://<%= request.host_with_port %><%=@client_application.oauth_server.request_token_path %>
</p> </p>
<p> <p>
<b>Access Token URL</b> http<%='s' if request.ssl? %>://<%= request.host_with_port %><%=@client_application.oauth_server.access_token_path %> <b><%= t'oauth.client_application.show.access_url' %></b> http<%='s' if request.ssl? %>://<%= request.host_with_port %><%=@client_application.oauth_server.access_token_path %>
</p> </p>
<p> <p>
<b>Authorize URL</b> http<%='s' if request.ssl? %>://<%= request.host_with_port %><%=@client_application.oauth_server.authorize_path %> <b><%= t'oauth.client_application.show.authorize_url' %></b> http<%='s' if request.ssl? %>://<%= request.host_with_port %><%=@client_application.oauth_server.authorize_path %>
</p> </p>
<p> <p><%= t'oauth.client_application.show.requests' %></p>
We support hmac-sha1 (recommended) as well as plain text in ssl mode. <ul><% @client_application.permissions.each do |perm| %>
</p> <div class="field">
<li><%= t('oauth.client_application.form.' + perm.to_s) %></li>
</div>
<% end %></ul>
<p><%= t'oauth.client_application.show.support_notice' %></p>
<p><%= link_to t('oauth.client_application.show.edit'), edit_oauth_client_url(@client_application) %></p>

View file

@ -46,39 +46,6 @@
<br /><br /> <br /><br />
<%= button_to t('user.account.make all my edits public button'), :action => :go_public %> <%= button_to t('user.account.make all my edits public button'), :action => :go_public %>
<% end %> <% end %>
<h2><%= t 'user.account.my apps' %></h2>
<% if @tokens.empty? %>
<p><%= t 'oauth.token.none' %></p>
<% else %>
<table>
<tr><th><%= t 'oauth.token.application' %></th><th><%= t 'oauth.token.issued' %></th><th>&nbsp;</th></tr>
<% @tokens.each do |token|%>
<% content_tag_for :tr, token do %>
<td><%= link_to token.client_application.name, token.client_application.url %></td>
<td><%= token.authorized_at %></td>
<td>
<% form_tag :controller => 'oauth', :action => 'revoke' do %>
<%= hidden_field_tag 'token', token.token %>
<%= submit_tag t('oauth.token.revoke') %>
<% end %>
</td>
<% end %>
<% end %>
</table>
<% end %>
<h2><%= t 'user.account.developers' %></h2>
<% if @user.client_applications.empty? %>
<p><%= t 'user.account.dev_intro', :link => "<a href=\"http://oauth.net\">OAuth</a>" %></p>
<p><%= link_to t('user.account.register_app'), :controller => 'oauth_clients', :action => :new %></p>
<% else %>
<p><%= t 'user.account.apps_registered' %></p>
<ul><% @user.client_applications.each do |client| %>
<li><% div_for client do %>
<%= link_to client.name, :controller => 'oauth_clients', :action => :show, :id => client.id %>
<% end %></li>
<% end %></ul>
<p><%= link_to t('user.account.register_another_app'), :controller => 'oauth_clients', :action => :new %></p>
<% end %>
<br/> <br/>
<br/> <br/>
<%= link_to t('user.account.return to profile'), :controller => 'user', :action => @user.display_name %> <%= link_to t('user.account.return to profile'), :controller => 'user', :action => @user.display_name %>

View file

@ -122,4 +122,6 @@
<br/> <br/>
<% if @user and @this_user.id == @user.id %> <% if @user and @this_user.id == @user.id %>
<%= link_to t('user.view.change your settings'), :controller => 'user', :action => 'account', :display_name => @user.display_name %> <%= link_to t('user.view.change your settings'), :controller => 'user', :action => 'account', :display_name => @user.display_name %>
<br/><br/>
<%= link_to t('user.view.my_oauth_details'), :controller => 'oauth_clients', :action => 'index' %>
<% end %> <% end %>

View file

@ -793,11 +793,52 @@ en:
allow_write_api: "modify the map." allow_write_api: "modify the map."
allow_read_gpx: "read your private GPS traces." allow_read_gpx: "read your private GPS traces."
allow_write_gpx: "upload GPS traces." allow_write_gpx: "upload GPS traces."
token: new:
none: "You have not authorised any clients to act on your behalf. You do not have to do anything now to authorise them, as they will ask for authorisation when they need it. After that time you can return here to revoke those permissions if you do not want the clients to have your authorisation any more." title: "Register a new application"
application: "Application" submit: "Register"
issued: "Issued" edit:
title: "Edit your application"
submit: "Edit"
show:
title: "OAuth details for {{app_name}}"
key: "Consumer Key:"
secret: "Consumer Secret:"
url: "Request Token URL:"
access_url: "Access Token URL:"
authorize_url: "Authorise URL:"
support_notice: "We support hmac-sha1 (recommended) as well as plain text in ssl mode."
edit: "Edit Details"
requests: "Requesting the following permissions from the user:"
allow_read_prefs: "read their user preferences."
allow_write_prefs: "modify their user preferences."
allow_write_diary: "create diary entries, comments and make friends."
allow_write_api: "modify the map."
allow_read_gpx: "read their private GPS traces."
allow_write_gpx: "upload GPS traces."
index:
title: "My OAuth Details"
my_tokens: "My Authorised Applications"
list_tokens: "The following tokens have been issued to applications in your name:"
application: "Application Name"
issued_at: "Issued At"
revoke: "Revoke!" revoke: "Revoke!"
my_apps: "My Client Applications"
no_apps: "Do you have an application you would like to register for use with us using the {{oauth}} standard? You must register your web application before it can make OAuth requests to this service."
registered_apps: "You have the following client applications registered:"
register_new: "Register your application"
form:
name: "Name"
required: "Required"
url: "Main Application URL"
callback_url: "Callback URL"
support_url: "Support URL"
requests: "Request the following permissions from the user:"
allow_read_prefs: "read their user preferences."
allow_write_prefs: "modify their user preferences."
allow_write_diary: "create diary entries, comments and make friends."
allow_write_api: "modify the map."
allow_read_gpx: "read their private GPS traces."
allow_write_gpx: "upload GPS traces."
user: user:
login: login:
title: "Login" title: "Login"
@ -870,6 +911,7 @@ en:
nearby users: "Nearby users: " nearby users: "Nearby users: "
no nearby users: "There are no users who admit to mapping nearby yet." no nearby users: "There are no users who admit to mapping nearby yet."
change your settings: change your settings change your settings: change your settings
my_oauth_details: "View my OAuth details"
friend_map: friend_map:
your location: Your location your location: Your location
nearby mapper: "Nearby mapper: " nearby mapper: "Nearby mapper: "
@ -896,12 +938,6 @@ en:
return to profile: Return to profile return to profile: Return to profile
flash update success confirm needed: "User information updated successfully. Check your email for a note to confirm your new email address." flash update success confirm needed: "User information updated successfully. Check your email for a note to confirm your new email address."
flash update success: "User information updated successfully." flash update success: "User information updated successfully."
my apps: "My client applications"
developers: "Application Developers"
dev_intro: "Have you written an application which you would like to register to make {{link}} requests to the OpenStreetMap server?"
register_app: "Register your application"
apps_registered: "You have the following client applications registered:"
register_another_app: "Register another application"
confirm: confirm:
heading: Confirm a user account heading: Confirm a user account
press confirm button: "Press the confirm button below to activate your account." press confirm button: "Press the confirm button below to activate your account."

View file

@ -7,15 +7,21 @@ class ClientApplicationTest < ActionController::IntegrationTest
# run through the procedure of creating a client application and checking # run through the procedure of creating a client application and checking
# that it shows up on the user's account page. # that it shows up on the user's account page.
def test_create_application def test_create_application
post '/login', {'user[email]' => "test@example.com", 'user[password]' => "test", :referer => '/user/test/account'} post '/login', {'user[email]' => "test@example.com", 'user[password]' => "test", :referer => '/user/test2'}
assert_response :redirect assert_response :redirect
follow_redirect! follow_redirect!
assert_response :success assert_response :success
assert_template 'user/account' assert_template 'user/view'
# check that the form to allow new client application creations exists # check that the form to allow new client application creations exists
assert_in_body do assert_in_body do
assert_select "h2", "Application Developers" assert_select "a[href='/oauth_clients']"
end
# now we follow the link to the oauth client list
get '/oauth_clients'
assert_response :success
assert_in_body do
assert_select "a[href='/oauth_clients/new']" assert_select "a[href='/oauth_clients/new']"
end end
@ -46,10 +52,10 @@ class ClientApplicationTest < ActionController::IntegrationTest
assert_equal 'Registered the information successfully', flash[:notice] assert_equal 'Registered the information successfully', flash[:notice]
# now go back to the account page and check its listed under this user # now go back to the account page and check its listed under this user
get '/user/test/account' get '/oauth_clients'
assert_response :success assert_response :success
assert_template 'user/account' assert_template 'oauth_clients/index'
assert_in_body { assert_select "li>div>a", "My New App" } assert_in_body { assert_select "div>a", "My New App" }
end end
## ##