- api_client_auth = ApiClientAuthorization.
- includes(:api_client, :user).
- where('api_token=? and (expires_at is null or expires_at > CURRENT_TIMESTAMP)', supplied_token).
- first
- if api_client_auth.andand.user
- user = api_client_auth.user
- api_client = api_client_auth.api_client
+ case supplied_token[0..2]
+ when 'v2,'
+ _, uuid, secret = supplied_token.split(',')
+ auth = ApiClientAuthorization.
+ includes(:api_client, :user).
+ where('uuid=? and api_token=? and (expires_at is null or expires_at > CURRENT_TIMESTAMP)',
+ uuid, secret).
+ first
+ else
+ auth = ApiClientAuthorization.
+ includes(:api_client, :user).
+ where('api_token=? and (expires_at is null or expires_at > CURRENT_TIMESTAMP)',
+ supplied_token).
+ first
+ end
+ if auth.andand.user
+ user = auth.user
+ api_client = auth.api_client