Commit c75aea5e authored by Timothy Andrew's avatar Timothy Andrew

Fix minor issues with the personal access tokens implementation.

- Use the `:personal_access_token` param root instead of
  `personal_access_token_params`, because we aren't using the
  `personal_access_token` param for authentication anymore (we're using
  `private_token` instead).
- Use `build` to instantiate a `PersonalAccessToken`
- Use better-formatted dates
parent 6d444331
......@@ -2,7 +2,7 @@ class Profiles::PersonalAccessTokensController < Profiles::ApplicationController
def index
@active_personal_access_tokens = current_user.personal_access_tokens.active.order(:expires_at)
@inactive_personal_access_tokens = current_user.personal_access_tokens.inactive
@personal_access_token = PersonalAccessToken.new(user: @user)
@personal_access_token = current_user.personal_access_tokens.build
end
def create
......@@ -28,8 +28,6 @@ class Profiles::PersonalAccessTokensController < Profiles::ApplicationController
private
def personal_access_token_params
# We aren't using `personal_access_token` as the root param because the authentication
# system expects to find a token string there - it's off-limits to us.
params.require(:personal_access_token_params).permit(:name, :expires_at)
params.require(:personal_access_token).permit(:name, :expires_at)
end
end
......@@ -12,7 +12,7 @@
Add a Personal Access Token
%p.profile-settings-content
Pick a name for the application, and we'll give you a unique token.
= form_for [:profile, @personal_access_token], as: "personal_access_token_params",
= form_for [:profile, @personal_access_token],
method: :post, html: { class: 'js-requires-input' } do |f|
.form-group
......@@ -29,7 +29,7 @@
%hr
%h5= "Active Personal Access Tokens (#{@active_personal_access_tokens.length})"
%h5 Active Personal Access Tokens (#{@active_personal_access_tokens.length})
- if @active_personal_access_tokens.present?
.table-responsive
......@@ -50,9 +50,9 @@
%div.input-group-btn
%button.btn.btn-default{ type: "button", data: { clipboard_text: token.token } }
%i.fa.fa-clipboard
%td= token.created_at.to_date
%td= token.created_at.to_date.to_s(:medium)
- if token.expires_at.present?
%td= token.expires_at.to_date
%td= token.expires_at.to_date.to_s(:medium)
- else
%td
%span.personal-access-tokens-never-expires-label Never
......@@ -63,7 +63,7 @@
%hr
%h5= "Inactive Personal Access Tokens (#{@inactive_personal_access_tokens.length})"
%h5 Inactive Personal Access Tokens (#{@inactive_personal_access_tokens.length})
- if @inactive_personal_access_tokens.present?
.table-responsive
......@@ -82,7 +82,7 @@
%div.input-group-btn
%button.btn.btn-default{ type: "button", data: { clipboard_text: token.token } }
%i.fa.fa-clipboard
%td= token.created_at.to_date
%td= token.created_at.to_date.to_s(:medium)
- else
%span No inactive tokens.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment