Commit fc4bce75 authored by Timothy Andrew's avatar Timothy Andrew

Make fixes based on @vsizov's comments on MR !3749

parent 4076bce5
......@@ -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
......
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
......
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