| 84 | } |
| 85 | |
| 86 | export function login (arg) { |
| 87 | if (!sourceToken.checkExistSource()) { |
| 88 | sourceToken.init() |
| 89 | } |
| 90 | |
| 91 | // Logout before login is called to purge any duplicate sessionkey cookies |
| 92 | postAPI('logout') |
| 93 | |
| 94 | const params = new URLSearchParams() |
| 95 | params.append('command', 'login') |
| 96 | params.append('username', arg.username || arg.email) |
| 97 | params.append('password', arg.password) |
| 98 | params.append('domain', arg.domain) |
| 99 | params.append('response', 'json') |
| 100 | return axios({ |
| 101 | url: '/', |
| 102 | method: 'POST', |
| 103 | data: params, |
| 104 | headers: { |
| 105 | 'content-type': 'application/x-www-form-urlencoded' |
| 106 | } |
| 107 | }) |
| 108 | } |
| 109 | |
| 110 | export async function logout () { |
| 111 | const result = await postAPI('logout').finally(() => { |