Make fixes based on @vsizov's comments on MR !3749
This commit is contained in:
parent
4076bce5d5
commit
fc4bce755d
|
@ -2,10 +2,6 @@ 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
|
||||
|
||||
# Prefer this to `@user.personal_access_tokens.new`, because it
|
||||
# litters the view's call to `@user.personal_access_tokens` with
|
||||
# this stub personal access token.
|
||||
@personal_access_token = PersonalAccessToken.new(user: @user)
|
||||
end
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
class PersonalAccessToken < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
|
||||
scope :active, -> { where(revoked: false).where("expires_at >= :current OR expires_at IS NULL", current: Time.current) }
|
||||
scope :inactive, -> { where("revoked = true OR expires_at < :current", current: Time.current) }
|
||||
scope :active, -> { where(revoked: false).where("expires_at >= NOW() OR expires_at IS NULL") }
|
||||
scope :inactive, -> { where("revoked = true OR expires_at < NOW()") }
|
||||
|
||||
def self.generate(params)
|
||||
personal_access_token = self.new(params)
|
||||
|
|
|
@ -42,7 +42,7 @@ module API
|
|||
identifier ||= params[SUDO_PARAM] || env[SUDO_HEADER]
|
||||
|
||||
# Regex for integers
|
||||
if !!(identifier =~ /^[0-9]+$/)
|
||||
if !!(identifier =~ /\A[0-9]+\z/)
|
||||
identifier.to_i
|
||||
else
|
||||
identifier
|
||||
|
|
Loading…
Reference in New Issue