# Readme for: ServerUtils_IsUserAuthorised_1_0_0

This method checks if a user is authorised using their JWT *(<u>J</u>SON <u>W</u>eb <u>T</u>oken)*.  

If a user is authorised they are allowed to continue and access the correct funtion that is being called.   
If the user is NOT Authorised, they will be rejected by the main index file on the server.

### How it works?
The method uses both the `authKeys`, `current` & `previous`, to decode the `JWT`.  
If one of them is successful, it will pass.  
If they are both unsuccessful, it will return a denied value.  
If the JWT is expired it will also fail.  

This is then returned to the main server function, that either allows the user to access the function called, or deny them by rejecting the request.  


## Expected Body Object

```JSON
{
  "jwt": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiVGVzdCBQZXJzb24iLCJmaXJzdE5hbWUiOiJUZXN0IiwibGFzdE5hbWUiOiJQZXJzb24iLCJlbWFpbCI6InRlc3RAdGVzdC50ZXN0IiwicGhvbmUiOiIwNDEyMzQ1Njc4Iiwib3JnYW5pc2F0aW9uIjoiVGVzdFh5cmlzIiwiaWF0IjoxNjIxOTk2Nzg0LCJleHAiOjE2MjIwMDAzODR9.CN4rGriJTZrs7CGrM1xjmY0QSRpD546Vx2q1YG3TjPM", // A signed JWT String
  "authKeys": {
    "current": "currentAuthKey", // The current Auth Key
    "previous": "previousAuthKey", // The previous Auth Key
  }
}
```

## Returned value

If the user is authorised:
```JSON
{
  "access": true
}
```

OR If the user is **NOT** authorised:
```JSON
{
  "access": false,
  "error": "Not Authorised, Log In"
}
```
