mirror of
https://github.com/simple-login/app.git
synced 2024-09-28 20:51:29 +02:00
Add /v2/setting/domains
This commit is contained in:
parent
ae64bd26b9
commit
f452c79aec
@ -97,3 +97,19 @@ def get_available_domains_for_random_alias():
|
|||||||
]
|
]
|
||||||
|
|
||||||
return jsonify(ret)
|
return jsonify(ret)
|
||||||
|
|
||||||
|
|
||||||
|
@api_bp.route("/v2/setting/domains")
|
||||||
|
@require_api_auth
|
||||||
|
def get_available_domains_for_random_alias_v2():
|
||||||
|
"""
|
||||||
|
Available domains for random alias
|
||||||
|
"""
|
||||||
|
user = g.user
|
||||||
|
|
||||||
|
ret = [
|
||||||
|
{"domain": domain, "is_custom": not is_sl}
|
||||||
|
for is_sl, domain in user.available_domains_for_random_alias()
|
||||||
|
]
|
||||||
|
|
||||||
|
return jsonify(ret)
|
||||||
|
36
docs/api.md
36
docs/api.md
@ -701,28 +701,30 @@ Input:
|
|||||||
|
|
||||||
Output: same as `GET /api/setting`
|
Output: same as `GET /api/setting`
|
||||||
|
|
||||||
#### GET /api/setting/domains
|
#### GET /api/v2/setting/domains
|
||||||
|
|
||||||
Return domains that user can use to create random alias
|
Return domains that user can use to create random alias
|
||||||
|
|
||||||
|
`is_custom` is true if this is a user's domain, otherwise false.
|
||||||
|
|
||||||
```json
|
```json
|
||||||
[
|
[
|
||||||
[
|
{
|
||||||
true,
|
"domain": "d1.test",
|
||||||
"d1.test"
|
"is_custom": false
|
||||||
],
|
},
|
||||||
[
|
{
|
||||||
true,
|
"domain": "d2.test",
|
||||||
"d2.test"
|
"is_custom": false
|
||||||
],
|
},
|
||||||
[
|
{
|
||||||
true,
|
"domain": "sl.local",
|
||||||
"sl.local"
|
"is_custom": false
|
||||||
],
|
},
|
||||||
[
|
{
|
||||||
false,
|
"domain": "ab.cd",
|
||||||
"ab.cd"
|
"is_custom": true
|
||||||
]
|
}
|
||||||
]
|
]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -65,3 +65,17 @@ def test_get_setting_domains(flask_client):
|
|||||||
[True, "sl.local"],
|
[True, "sl.local"],
|
||||||
[False, "ab.cd"],
|
[False, "ab.cd"],
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def test_get_setting_domains_v2(flask_client):
|
||||||
|
user = login(flask_client)
|
||||||
|
CustomDomain.create(user_id=user.id, domain="ab.cd", verified=True, commit=True)
|
||||||
|
|
||||||
|
r = flask_client.get("/api/v2/setting/domains")
|
||||||
|
assert r.status_code == 200
|
||||||
|
assert r.json == [
|
||||||
|
{"domain": "d1.test", "is_custom": False},
|
||||||
|
{"domain": "d2.test", "is_custom": False},
|
||||||
|
{"domain": "sl.local", "is_custom": False},
|
||||||
|
{"domain": "ab.cd", "is_custom": True},
|
||||||
|
]
|
||||||
|
Loading…
Reference in New Issue
Block a user