big oauth improvements
This commit is contained in:
@@ -1,19 +1,17 @@
|
||||
|
||||
module.exports = (sequelize, DataTypes) => {
|
||||
const OAuthClient = sequelize.define('oauth_client', {
|
||||
client_id: {
|
||||
id: {
|
||||
type: DataTypes.STRING,
|
||||
primaryKey: true
|
||||
primaryKey: true,
|
||||
allowNull: false
|
||||
},
|
||||
name: DataTypes.STRING,
|
||||
scopes: DataTypes.STRING,
|
||||
client_secret: DataTypes.STRING,
|
||||
redirectUris: DataTypes.STRING
|
||||
scopes: DataTypes.STRING,
|
||||
redirectUris: DataTypes.STRING,
|
||||
website: DataTypes.STRING
|
||||
}, {})
|
||||
|
||||
OAuthClient.associate = function (models) {
|
||||
OAuthClient.belongsTo(models.user)
|
||||
}
|
||||
|
||||
return OAuthClient
|
||||
}
|
||||
|
||||
@@ -5,13 +5,14 @@ module.exports = (sequelize, DataTypes) => {
|
||||
type: DataTypes.STRING,
|
||||
primaryKey: true
|
||||
},
|
||||
expiresAt: DataTypes.DATE,
|
||||
scope: DataTypes.STRING,
|
||||
redirect_uri: DataTypes.STRING
|
||||
}, {})
|
||||
|
||||
OAuthCode.associate = function (models) {
|
||||
OAuthCode.belongsTo(models.user)
|
||||
OAuthCode.belongsTo(models.oauth_client)
|
||||
OAuthCode.belongsTo(models.oauth_client, { as: 'client' })
|
||||
}
|
||||
|
||||
return OAuthCode
|
||||
|
||||
@@ -1,14 +1,30 @@
|
||||
|
||||
module.exports = (sequelize, DataTypes) => {
|
||||
const OAuthToken = sequelize.define('oauth_token', {
|
||||
access_token: DataTypes.STRING,
|
||||
refresh_token: DataTypes.STRING,
|
||||
scope: DataTypes.STRING,
|
||||
accessToken: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
primaryKey: true
|
||||
},
|
||||
accessTokenExpiresAt: {
|
||||
type: DataTypes.DATE,
|
||||
get () {
|
||||
return new Date(this.getDataValue('accesTokenExpiresAt'))
|
||||
}
|
||||
},
|
||||
refreshToken: DataTypes.STRING,
|
||||
refreshTokenExpiresAt: {
|
||||
type: DataTypes.DATE,
|
||||
get () {
|
||||
return new Date(this.getDataValue('accesTokenExpiresAt'))
|
||||
}
|
||||
},
|
||||
scope: DataTypes.STRING
|
||||
}, {})
|
||||
|
||||
OAuthToken.associate = function (models) {
|
||||
OAuthToken.belongsTo(models.user)
|
||||
OAuthToken.belongsTo(models.oauth_client)
|
||||
OAuthToken.belongsTo(models.oauth_client, { as: 'client' })
|
||||
}
|
||||
|
||||
return OAuthToken
|
||||
|
||||
Reference in New Issue
Block a user