diff options
| author | 2023-04-28 08:28:17 +0200 | |
|---|---|---|
| committer | 2023-04-28 08:28:17 +0200 | |
| commit | b620fe99fa99bb1658f43741b2d40ce88ff53963 (patch) | |
| tree | fbbd8646043ebf4fb7123180e768d85383c0b656 | |
| parent | Updated RELEASE_NOTES. (diff) | |
| download | snac2-b620fe99fa99bb1658f43741b2d40ce88ff53963.tar.gz snac2-b620fe99fa99bb1658f43741b2d40ce88ff53963.tar.xz snac2-b620fe99fa99bb1658f43741b2d40ce88ff53963.zip | |
Ensure the new app client_id is unique.
| -rw-r--r-- | mastoapi.c | 13 |
1 files changed, 12 insertions, 1 deletions
| @@ -1522,9 +1522,20 @@ int mastoapi_post_handler(const xs_dict *req, const char *q_path, | |||
| 1522 | if (name && ruri) { | 1522 | if (name && ruri) { |
| 1523 | xs *app = xs_dict_new(); | 1523 | xs *app = xs_dict_new(); |
| 1524 | xs *id = xs_replace_i(tid(0), ".", ""); | 1524 | xs *id = xs_replace_i(tid(0), ".", ""); |
| 1525 | xs *cid = random_str(); | ||
| 1526 | xs *csec = random_str(); | 1525 | xs *csec = random_str(); |
| 1527 | xs *vkey = random_str(); | 1526 | xs *vkey = random_str(); |
| 1527 | xs *cid = NULL; | ||
| 1528 | |||
| 1529 | /* pick a non-existent random cid */ | ||
| 1530 | for (;;) { | ||
| 1531 | cid = random_str(); | ||
| 1532 | xs *p_app = app_get(cid); | ||
| 1533 | |||
| 1534 | if (p_app == NULL) | ||
| 1535 | break; | ||
| 1536 | |||
| 1537 | xs_free(cid); | ||
| 1538 | } | ||
| 1528 | 1539 | ||
| 1529 | app = xs_dict_append(app, "name", name); | 1540 | app = xs_dict_append(app, "name", name); |
| 1530 | app = xs_dict_append(app, "redirect_uri", ruri); | 1541 | app = xs_dict_append(app, "redirect_uri", ruri); |