- For example, you can use a username and password to register without an email address
- For example, you can customize a login and registration page. Just pass the data through the API to the FlARUM API to register
Is the above method feasible?
@askvortsov @luceos
How to Custom Registration Account From FLARUM
- Edited
BILLFuYiWei Flarum currently requires an email address for all users. But the second point is definitely feasible.
- Edited
askvortsov Thank you for your reply. there is a problem with the second point, when I call this API
POST /api/users - register a new user
it prompts an error
{
"errors": [
{
"status": "400",
"code": "csrf_token_mismatch"
}
]
}
What should I do to fix it? askvortsov ,
I'm using this API doc https://github.com/flarum/flarum.github.io. Is it too old?
- Edited
BILLFuYiWei POST /api/users
still exists. But you need to use an API key or access token to bypass the CSRF protection.
The GitHub repository you linked doesn't contain any documentation (I think?). Official documentation is at https://docs.flarum.org/ but I think the page about API keys is still missing. There's information on how to create those keys somewhere on the forum but I don't have the link right now.
- Edited
clarkwinkelmann Thank you for your reply. I finally find it https://discuss.flarum.org/d/22477-about-cookie-and-x-csrf-token
I have a new problem when I call this interface post api/users
, it returns an error
{
"errors": [
{
"status": "422",
"code": "validation_error",
"detail": "username 不能为空。",
"source": {
"pointer": "/data/attributes/username"
}
},
{
"status": "422",
"code": "validation_error",
"detail": "email 不能为空。",
"source": {
"pointer": "/data/attributes/email"
}
},
{
"status": "422",
"code": "validation_error",
"detail": "password 不能为空。",
"source": {
"pointer": "/data/attributes/password"
}
}
]
}
I tried any away to request this API, Body, Params, form-data.
I requested this interface using the Postman tool,
What should I do?
BILLFuYiWei what's your payload?
JSON:API syntax is something like this:
{
"data": {
"attributes": {
"email": ""
}
}
}
clarkwinkelmann Thank you very much, It's working now, my payload before is
{
"data": {
"username": "test1122",
"email": "test1122@qq.com",
"password": "12345678",
"nickname": "test1122"
}
}
BILLFuYiWei mate ,does flarum add your 'nickname' into database automatically?
HudsonAustralia it does