wekan / wekan

The Open Source kanban (built with Meteor). Keep variable/table/field names camelCase. For translations, only add Pull Request changes to wekan/i18n/en.i18n.json , other translations are done at https://app.transifex.com/wekan/wekan only.
https://wekan.github.io
MIT License
19.6k stars 2.83k forks source link

Cannot login via API #2849

Closed ViViDboarder closed 4 years ago

ViViDboarder commented 4 years ago

Issue

I am unable to login to Wekan using the login API. In addition, I am not seeing any logs despite having DEBUG=true set.

I'm using the docker-compose.yml file found here. Only change I've done is uncomment the line for DEBUG.

Server Setup Information:

Problem description:

# Download the example `docker-compose.yml` file
wget https://raw.githubusercontent.com/wekan/wekan/master/docker-compose.yml
# uncomment the DEBUG env variable
sed -i '' 's/#- DEBUG/- DEBUG/' docker-compose.yml
# start wekan
docker-compose up -d
# open wekan and create first user
open http://localhost
# create new user as admin:password and log in, this works despite an error trying to create user due to invalid SMTP
# attempt to authenticate with curl using documented example
curl -X POST -F 'username=admin' -F "password=password" -H 'Content-Type: application/x-www-form-urlencoded' -H 'Accept: */*' http://localhost/users/login

# Output:
# {
#   "error": 400,
#   "reason": "Match failed"
# }

# check logs
docker-compose logs --tail=20 wekan

# Output
# wekan-app  | > Finishing mutate-boardIds-in-customfields migration.
# wekan-app  | > Starting add-missing-created-and-modified migration.
# wekan-app  | > Finishing add-missing-created-and-modified migration.
# wekan-app  | > Starting fix-incorrect-dates migration.
# wekan-app  | > Finishing fix-incorrect-dates migration.
# wekan-app  | Successfully added createdAt and updatedAt to all tables
# wekan-app  | > Starting add-assignee migration.
# wekan-app  | > Finishing add-assignee migration.
# wekan-app  | > Starting add-profile-showDesktopDragHandles migration.
# wekan-app  | > Finishing add-profile-showDesktopDragHandles migration.
# wekan-app  | > Starting add-profile-hiddenMinicardLabelText migration.
# wekan-app  | > Finishing add-profile-hiddenMinicardLabelText migration.
# wekan-app  | Meteor APM: completed instrumenting the app
# wekan-app  | Exception while invoking method 'ATCreateUserServer' { [object Object]
# wekan-app  |   errno: 'ECONNREFUSED',
# wekan-app  |   code: 'ECONNECTION',
# wekan-app  |   syscall: 'connect',
# wekan-app  |   address: '127.0.0.1',
# wekan-app  |   port: 587,
# wekan-app  |   command: 'CONN' }

# These logs only show up to the point that the user was created and no login attempt is shown.
xet7 commented 4 years ago

Login as form data to get Bearer token: https://github.com/wekan/wekan/wiki/REST-API#example-call---as-form-data

ViViDboarder commented 4 years ago

That's the same thing that -F does. I get the exact same results doing using the example there

curl -X POST -d "username=admin&assword=password" http://localhost/users/login
# Output:
# {
#   "error": 400,
#   "reason": "Match failed"
# }
xet7 commented 4 years ago

I do get Bearer token just fine:

docker-compose up -d

curl http://localhost/users/login -d "username=username&password=password"

{"id":"Bjji12345","token":"pcG2pqaAh7ldLlZR12345","tokenExpires":"2020-03-10T23:36:27.210Z"}
ViViDboarder commented 4 years ago

Well... That's embarrassing... In my second example there, it actually does work, but I had a typo... The parameter should be password, not assword. 😉

ViViDboarder commented 4 years ago

I'm not sure why the first version didn't work, but I'm switching to using the JSON request instead.

Any idea why logs aren't showing? Though it's now working using the same docker-compose, it's not working on my production server and there are no logs to debug.