---
# System prepended metadata

title: 登入

---

# 登入
## A. 第一次登入，回傳隱私權政策

Attribute | Description | IsRequired| Remark
-|-|-|-
username | String | true | 帳號
password | String | true | 密碼
device | String | true | 設備名稱

Request:
```url=
POST /user/login
```

Payload：
```json=
{
    "username": "test",
    "password": "123",
    "device": "pc"   
}
```

Attribute | Description | Remark
-|-|-
data.token | String | token
data.expiredAt | timeStamp | 到期日期
data.id | String | 使用者Id
detail.sequenceId | String | 暫存ID
msg | String | 錯誤訊息
code | String | 101(找不到使用者)/102(密碼錯誤)/103(重複登入)/105(未同意隱私權)

Response (成功):
```json=
{
    "success": true,
    "data": {
        "token": "9CFI827UEI0081-19234IUHW9W",
        "expiredAt": 1583991833330,
        "id": "101"
    }
}
```
Response (帳號已登入)
```json=
{
    "success": false,
    "code": 103,
    "detail": {
        "sequenceId": "123456789",
    }
}
```
Response (尚未登入EULA)
```json=
{
    "success": false,
    "code": 105,
    "msg": "登入失敗，用戶第一次登入，請同意隱私權政策",
    "detail": {
        "sequenceId": "123456789",
    }
}
```

## B.重複登入(強迫登入，踢掉上一個使用者)
Request:
```url=
POST /user/login/$sequenceId
```
```json=
{
    "success": true,
    "data": {
        "token": "9CFI827UEI0081-19234IUHW9W",
        "expiredAt": 1583991833330,
        "id": "101"
    }
}
```

## C.同意 EULA 並登入
* 寫入資料庫，下次登入不必再次同意
Request:
```url=
POST /user/login/eula/$sequenceId
```
Response
```json=
{
    "success": true,
    "data": {
        "token": "9CFI827UEI0081-19234IUHW9W",
        "expiredAt": 1583991833330,
        "id": "101"
    }
}
```