/**
* @module flitter-auth/model/Oauth2AuthorizationTicket
*/
const Model = require('flitter-orm/src/model/Model')
const uuid = require('uuid/v4')
/**
* Flitter model specification for a single-use auth code
* used to retrieve an OAuth2 bearer token.
* @extends module:flitter-orm/src/model/Model~Model
*/
class Oauth2AuthorizationTicket extends Model {
/**
* Get the schema for this model.
* @returns {object}
*/
static get schema() {
return {
client_id: String,
user_id: String,
token: {type: String, default: uuid},
redeemed: {type: Boolean, default: false},
expires: {
type: Date,
default: () => {
const date = new Date()
date.setHours( date.getHours()+6 )
return date
}
},
}
}
}
module.exports = exports = Oauth2AuthorizationTicket