romantulchak / virtual-pet-core

2 stars 0 forks source link

Controllers

image

API AuthController

image

Sign in

image

Request
{
  "password": "1834asd",
  "username": "test1"
}
Response code 200
{
  "token": "eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJ0ZXN0MSIsImlhdCI6MTYwNzQ1NjIzNSwiZXhwIjoxNjA3NTQyNjM1fQ.zZj1eOLz10sNdkzTuI7rnbgzOGrRdl63-zrnyaWiEGf7f0IEhuS3lDlfy8elYyl4AJS32TJhMYSdbQaJBHRAsA",
  "id": 3,
  "username": "test1",
  "email": "test1@gmail.com",
  "roles": [
    "ROLE_USER"
  ],
  "tokenType": "Bearer"
} 
Response code 401
{
  "timestamp": "2020-12-08T19:42:49.616+00:00",
  "status": 401,
  "error": "Unauthorized",
  "message": "",
  "path": "/api/auth/signin"
}

Sign up

image

Request
{
  "email": "test2@gmail.com",
  "password": "1834asd",
  "role": [
    "user"
  ],
  "username": "test234"
}
Response code 200
{
  "message": "User registered successfully!"
}
Response code 400
{
  "message": "Error: Username is already taken!"
}
Response code 400 the same Email
{
  "message": "Error: Email is already in use!"
}