Move user schemas so they can be imported

pull/218/head
Tiger Oakes 4 years ago
parent fe7a3075d6
commit 70d1afce76

@ -695,35 +695,13 @@ paths:
content:
application/json:
schema:
type: object
properties:
user:
$ref: '#/components/schemas/User'
token:
type: string
permissions:
type: array
items:
type: string
available_permissions:
type: array
items:
type: string
$ref: '#/components/schemas/LoginResponse'
description: Use this method to log into a user using their username and password and receive a jwt auth token so you can send per-user requests.
requestBody:
content:
application/json:
schema:
type: object
properties:
userid:
type: string
description: 'This is the username, not the user uid'
password:
type: string
required:
- userid
- password
$ref: '#/components/schemas/LoginRequest'
security:
- Auth query parameter: []
tags:
@ -738,27 +716,13 @@ paths:
content:
application/json:
schema:
type: object
properties:
user:
$ref: '#/components/schemas/User'
$ref: '#/components/schemas/RegisterResponse'
description: Use this endpoint to register a user. It will only work if registration is enabled.
requestBody:
content:
application/json:
schema:
type: object
properties:
userid:
type: string
username:
type: string
password:
type: string
required:
- userid
- username
- password
$ref: '#/components/schemas/RegisterRequest'
security:
- Auth query parameter: []
tags:
@ -778,21 +742,7 @@ paths:
content:
application/json:
schema:
type: object
properties:
change_object:
required:
- uid
type: object
properties:
uid:
type: string
name:
type: string
role:
type: string
required:
- change_object
$ref: '#/components/schemas/UpdateUserRequest'
description: Updates certain properties for a user. Only two are possible right now.
security:
- Auth query parameter: []
@ -814,12 +764,7 @@ paths:
content:
application/json:
schema:
type: object
properties:
uid:
type: string
required:
- uid
$ref: '#/components/schemas/DeleteUserRequest'
security:
- Auth query parameter: []
tags:
@ -834,25 +779,7 @@ paths:
content:
application/json:
schema:
type: object
properties:
roles:
type: object
properties:
admin:
type: object
properties:
permissions:
type: array
items:
$ref: '#/components/schemas/UserPermission'
user:
type: object
properties:
permissions:
type: array
items:
$ref: '#/components/schemas/UserPermission'
$ref: '#/components/schemas/GetRolesResponse'
description: Gets the available roles and their permissions
security:
- Auth query parameter: []
@ -910,12 +837,7 @@ paths:
content:
application/json:
schema:
type: object
properties:
users:
type: array
items:
$ref: '#/components/schemas/User'
$ref: '#/components/schemas/GetUsersResponse'
description: 'Gets all users, returns a list of the user objects including their user permissions, videos, playlists, subscriptions, etc.'
security:
- Auth query parameter: []
@ -1695,6 +1617,103 @@ components:
properties:
id:
type: string
RegisterRequest:
required:
- userid
- username
- password
type: object
properties:
userid:
type: string
username:
type: string
password:
type: string
RegisterResponse:
type: object
properties:
user:
$ref: '#/components/schemas/User'
LoginRequest:
required:
- username
- password
type: object
properties:
username:
type: string
password:
type: string
LoginResponse:
type: object
properties:
user:
$ref: '#/components/schemas/User'
token:
type: string
permissions:
type: array
items:
$ref: '#/components/schemas/UserPermission'
available_permissions:
type: array
items:
$ref: '#/components/schemas/UserPermission'
UpdateUserRequest:
required:
- change_object
type: object
properties:
change_object:
required:
- uid
type: object
properties:
uid:
type: string
name:
type: string
role:
type: string
DeleteUserRequest:
required:
- uid
type: object
properties:
uid:
type: string
GetUsersResponse:
required:
- users
type: object
properties:
users:
type: array
items:
$ref: '#/components/schemas/User'
GetRolesResponse:
required:
- roles
type: object
properties:
roles:
type: object
properties:
admin:
type: object
properties:
permissions:
type: array
items:
$ref: '#/components/schemas/UserPermission'
user:
type: object
properties:
permissions:
type: array
items:
$ref: '#/components/schemas/UserPermission'
securitySchemes:
Auth query parameter:
name: apiKey

@ -19,6 +19,7 @@ import type {
DeleteMp3Mp4Request,
DeletePlaylistRequest,
DeleteSubscriptionFileRequest,
DeleteUserRequest,
DownloadArchiveRequest,
DownloadFileRequest,
FileType,
@ -34,13 +35,19 @@ import type {
GetMp4sResponse,
GetPlaylistRequest,
GetPlaylistResponse,
GetRolesResponse,
GetSubscriptionRequest,
GetSubscriptionResponse,
GetUsersResponse,
LoginRequest,
LoginResponse,
Mp3DownloadRequest,
Mp3DownloadResponse,
Mp4DownloadRequest,
Mp4DownloadResponse,
Playlist,
RegisterRequest,
RegisterResponse,
SetConfigRequest,
SharingToggle,
SubscribeRequest,
@ -53,6 +60,7 @@ import type {
UpdatePlaylistFilesRequest,
UpdatePlaylistRequest,
UpdateServerRequest,
UpdateUserRequest,
UserPermission,
YesNo,
} from '../api-types';
@ -444,9 +452,9 @@ export class PostsService implements CanActivate {
}
// user methods
login(username, password) {
const call = this.http.post(this.path + 'auth/login', {username: username, password: password}, this.httpOptions);
return call;
login(username: string, password: string) {
const body: LoginRequest = {username: username, password: password};
return this.http.post<LoginResponse>(this.path + 'auth/login', body, this.httpOptions);
}
// user methods
@ -481,10 +489,11 @@ export class PostsService implements CanActivate {
}
// user methods
register(username, password) {
const call = this.http.post(this.path + 'auth/register', {userid: username,
username: username,
password: password}, this.httpOptions);
register(username: string, password: string) {
const body: RegisterRequest = {userid: username,
username: username,
password: password}
const call = this.http.post<RegisterResponse>(this.path + 'auth/register', body, this.httpOptions);
return call;
}
@ -529,10 +538,11 @@ export class PostsService implements CanActivate {
return this.http.post(this.path + 'auth/adminExists', {}, this.httpOptions);
}
createAdminAccount(password) {
return this.http.post(this.path + 'auth/register', {userid: 'admin',
username: 'admin',
password: password}, this.httpOptions);
createAdminAccount(password: string) {
const body: RegisterRequest = {userid: 'admin',
username: 'admin',
password: password};
return this.http.post<RegisterResponse>(this.path + 'auth/register', body, this.httpOptions);
}
checkAdminCreationStatus(force_show = false) {
@ -547,12 +557,14 @@ export class PostsService implements CanActivate {
});
}
changeUser(change_obj) {
return this.http.post<SuccessObject>(this.path + 'updateUser', {change_object: change_obj}, this.httpOptions);
changeUser(change_obj: UpdateUserRequest['change_object']) {
const body: UpdateUserRequest = {change_object: change_obj};
return this.http.post<SuccessObject>(this.path + 'updateUser', body, this.httpOptions);
}
deleteUser(uid) {
return this.http.post<SuccessObject>(this.path + 'deleteUser', {uid: uid}, this.httpOptions);
deleteUser(uid: string) {
const body: DeleteUserRequest = {uid: uid};
return this.http.post<SuccessObject>(this.path + 'deleteUser', body, this.httpOptions);
}
changeUserPassword(user_uid, new_password) {
@ -560,11 +572,11 @@ export class PostsService implements CanActivate {
}
getUsers() {
return this.http.post(this.path + 'getUsers', {}, this.httpOptions);
return this.http.post<GetUsersResponse>(this.path + 'getUsers', {}, this.httpOptions);
}
getRoles() {
return this.http.post(this.path + 'getRoles', {}, this.httpOptions);
return this.http.post<GetRolesResponse>(this.path + 'getRoles', {}, this.httpOptions);
}
setUserPermission(user_uid: string, permission: UserPermission, new_value: YesNo) {

Loading…
Cancel
Save