Skip to content

Commit

Permalink
fix(auth): Make verify GET'
Browse files Browse the repository at this point in the history
  • Loading branch information
HagerDakroury committed Jul 14, 2021
1 parent 5063db0 commit b5fba7b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
3 changes: 1 addition & 2 deletions auth/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@

```json
{
"username": "hager",
"email": "[email protected]",
"password": "12345678"
}
Expand Down Expand Up @@ -88,7 +87,7 @@

- **verify**

POST
GET

http://178.128.140.169:4002/api/v1/auth/verify

Expand Down
18 changes: 8 additions & 10 deletions auth/src/routes/verify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ dotenv.config();

const router = express.Router();

router.post(`${baseUrl}/verify`, (req, res) => {
router.get(`${baseUrl}/verify`, (req, res) => {
const token = req.header("Authorization")?.split(" ")[1];
const role = req.body.role;
if (!token) {
Expand All @@ -20,15 +20,13 @@ router.post(`${baseUrl}/verify`, (req, res) => {
if (role && payload.role != role) {
return res.status(400).send("Role not authorized");
}
return res
.status(200)
.send({
message: "Verified",
_id: payload._id,
username: payload.username,
email: payload.email,
role: payload.role,
});
return res.status(200).send({
message: "Verified",
_id: payload._id,
username: payload.username,
email: payload.email,
role: payload.role,
});
} catch (err) {
return res.status(400).send("Invalid Token");
}
Expand Down

0 comments on commit b5fba7b

Please sign in to comment.