mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-04 02:09:37 +02:00
server/server -> server/core
This commit is contained in:
parent
114327d4ce
commit
5a3d0650c9
838 changed files with 111 additions and 111 deletions
63
server/core/models/oauth/oauth-client.ts
Normal file
63
server/core/models/oauth/oauth-client.ts
Normal file
|
@ -0,0 +1,63 @@
|
|||
import { AllowNull, Column, CreatedAt, DataType, HasMany, Model, Table, UpdatedAt } from 'sequelize-typescript'
|
||||
import { AttributesOnly } from '@peertube/peertube-typescript-utils'
|
||||
import { OAuthTokenModel } from './oauth-token.js'
|
||||
|
||||
@Table({
|
||||
tableName: 'oAuthClient',
|
||||
indexes: [
|
||||
{
|
||||
fields: [ 'clientId' ],
|
||||
unique: true
|
||||
},
|
||||
{
|
||||
fields: [ 'clientId', 'clientSecret' ],
|
||||
unique: true
|
||||
}
|
||||
]
|
||||
})
|
||||
export class OAuthClientModel extends Model<Partial<AttributesOnly<OAuthClientModel>>> {
|
||||
|
||||
@AllowNull(false)
|
||||
@Column
|
||||
clientId: string
|
||||
|
||||
@AllowNull(false)
|
||||
@Column
|
||||
clientSecret: string
|
||||
|
||||
@Column(DataType.ARRAY(DataType.STRING))
|
||||
grants: string[]
|
||||
|
||||
@Column(DataType.ARRAY(DataType.STRING))
|
||||
redirectUris: string[]
|
||||
|
||||
@CreatedAt
|
||||
createdAt: Date
|
||||
|
||||
@UpdatedAt
|
||||
updatedAt: Date
|
||||
|
||||
@HasMany(() => OAuthTokenModel, {
|
||||
onDelete: 'cascade'
|
||||
})
|
||||
OAuthTokens: Awaited<OAuthTokenModel>[]
|
||||
|
||||
static countTotal () {
|
||||
return OAuthClientModel.count()
|
||||
}
|
||||
|
||||
static loadFirstClient () {
|
||||
return OAuthClientModel.findOne()
|
||||
}
|
||||
|
||||
static getByIdAndSecret (clientId: string, clientSecret: string) {
|
||||
const query = {
|
||||
where: {
|
||||
clientId,
|
||||
clientSecret
|
||||
}
|
||||
}
|
||||
|
||||
return OAuthClientModel.findOne(query)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue