-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from TransDB-de/cms-auth
Add auth via cms account
- Loading branch information
Showing
20 changed files
with
259 additions
and
474 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# EditorConfig is awesome: https://editorconfig.org | ||
|
||
# top-most EditorConfig file | ||
root = true | ||
|
||
# Unix-style newlines with a newline ending every file | ||
[*] | ||
charset = utf-8 | ||
indent_style = tab | ||
indent_size = 4 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { | ||
Controller, | ||
Middleware, | ||
Post, | ||
} from "@overnightjs/core"; | ||
import { IRequest, IResponse } from "express"; | ||
import rateLimit from "express-rate-limit"; | ||
|
||
import { | ||
LoginBody, | ||
} from "../models/request/users.request.js"; | ||
import validate from "../middleware/validation.middleware.js"; | ||
|
||
import * as UserService from "../services/users.service.js"; | ||
import { config } from "../services/config.service.js"; | ||
|
||
const loginRateLimiter = rateLimit({ | ||
windowMs: config.rateLimit.login.timeframeMinutes * 60 * 1000, | ||
max: config.rateLimit.login.maxRequests, | ||
}); | ||
|
||
@Controller("access") | ||
export default class UsersController { | ||
@Post("login") | ||
@Middleware(loginRateLimiter) | ||
@Middleware(validate(LoginBody)) | ||
async login(req: IRequest<LoginBody>, res: IResponse) { | ||
let login = await UserService.login(req.body); | ||
|
||
if (!login) return res.error!("wrong_credentials"); | ||
|
||
res.send(login); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
query { | ||
management_users { | ||
user { | ||
id | ||
first_name | ||
last_name | ||
} | ||
status | ||
admin | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
query { | ||
users_me { | ||
id | ||
first_name | ||
last_name | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
query { | ||
users { | ||
id | ||
first_name | ||
last_name | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,7 @@ | ||
import { DatabaseUser } from "../../models/database/user.model.js" | ||
import ResponseBody from "../../models/response.js" | ||
|
||
export interface PublicUser extends Pick< DatabaseUser<"out">, "username" | "email" | "registerDate" | "lastLogin" | "admin"> { | ||
password?: never; | ||
} | ||
|
||
|
||
export interface PasswordReset extends ResponseBody { | ||
password: string; | ||
export interface PublicUser extends ResponseBody { | ||
id: string; | ||
username: string; | ||
admin: boolean; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.