mirror of https://github.com/veypi/OneAuth.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
958 B
TypeScript
45 lines
958 B
TypeScript
|
3 years ago
|
/*
|
||
|
|
* user.ts
|
||
|
|
* Copyright (C) 2023 veypi <i@veypi.com>
|
||
|
|
* 2023-10-05 15:37
|
||
|
|
* Distributed under terms of the MIT license.
|
||
|
|
*/
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
import { Base64 } from 'js-base64'
|
||
|
|
import ajax from './axios'
|
||
|
|
import { Cfg } from './setting'
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
export default {
|
||
|
|
local: () => Cfg.BaseUrl() + '/user/',
|
||
|
|
register(username: string, password: string, prop?: any) {
|
||
|
|
const data = Object.assign({
|
||
|
|
username: username,
|
||
|
|
password: Base64.encode(password),
|
||
|
|
}, prop)
|
||
|
|
return ajax.post(this.local(), data)
|
||
|
|
},
|
||
|
|
login(username: string, password: string) {
|
||
|
|
return ajax.head(this.local() + username, {
|
||
|
|
typ: 'username',
|
||
|
|
password: Base64.encode(password),
|
||
|
|
})
|
||
|
|
},
|
||
|
|
search(q: string) {
|
||
|
|
return ajax.get(this.local(), { username: q })
|
||
|
|
},
|
||
|
|
get(id: number) {
|
||
|
|
return ajax.get(this.local() + id)
|
||
|
|
},
|
||
|
|
list() {
|
||
|
|
return ajax.get(this.local())
|
||
|
|
},
|
||
|
|
update(id: number, props: any) {
|
||
|
|
return ajax.patch(this.local() + id, props)
|
||
|
|
},
|
||
|
|
}
|
||
|
|
|