mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-25 14:35:04 +00:00
Ensure the new app client_id is unique.
This commit is contained in:
parent
e0cc5752b0
commit
b620fe99fa
1 changed files with 12 additions and 1 deletions
13
mastoapi.c
13
mastoapi.c
|
@ -1522,9 +1522,20 @@ int mastoapi_post_handler(const xs_dict *req, const char *q_path,
|
||||||
if (name && ruri) {
|
if (name && ruri) {
|
||||||
xs *app = xs_dict_new();
|
xs *app = xs_dict_new();
|
||||||
xs *id = xs_replace_i(tid(0), ".", "");
|
xs *id = xs_replace_i(tid(0), ".", "");
|
||||||
xs *cid = random_str();
|
|
||||||
xs *csec = random_str();
|
xs *csec = random_str();
|
||||||
xs *vkey = random_str();
|
xs *vkey = random_str();
|
||||||
|
xs *cid = NULL;
|
||||||
|
|
||||||
|
/* pick a non-existent random cid */
|
||||||
|
for (;;) {
|
||||||
|
cid = random_str();
|
||||||
|
xs *p_app = app_get(cid);
|
||||||
|
|
||||||
|
if (p_app == NULL)
|
||||||
|
break;
|
||||||
|
|
||||||
|
xs_free(cid);
|
||||||
|
}
|
||||||
|
|
||||||
app = xs_dict_append(app, "name", name);
|
app = xs_dict_append(app, "name", name);
|
||||||
app = xs_dict_append(app, "redirect_uri", ruri);
|
app = xs_dict_append(app, "redirect_uri", ruri);
|
||||||
|
|
Loading…
Reference in a new issue