Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contollers #52

Merged
merged 4 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ name: "CodeQL"

on:
push:
branches: [ "main", "controllers" ]
branches: [ "main" ]
pull_request:
branches: [ "main" ]
schedule:
Expand Down
8 changes: 5 additions & 3 deletions server/controllers/auth/registerController.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,16 @@ export default async function registerController(req, res) {
}

// Check if password and username are the same or if password contains the username
if (password === username) {
if (password && username && password === username) {
inputErrors.push("The password and username cannot be the same");
}

if (password.replace(/[^a-zA-Z]+/g, "").includes(username.replace(/[^a-zA-Z]+/g, ""))) {
if (password && username && password.replace(/[^a-zA-Z]+/g, "").includes(username.replace(/[^a-zA-Z]+/g, ""))) {
inputErrors.push("Password should not contain the username");
}

console.log(useragent.parse(req.headers['user-agent']));

// If there are any validation errors, return a 400 status code and the error messages
if (inputErrors.length > 0) {
return res.status(400).json({ messages: inputErrors });
Expand All @@ -80,7 +82,7 @@ export default async function registerController(req, res) {
const userAgent = agent.toString(); // Full user-agent string
const browser = agent.toAgent(); // Browser name and version
const operatingSystem = agent.os.toString(); // Operating system name and version
const deviceType = agent.os.family; // Get the operating system from the parsed user agent
let deviceType = agent.os.family; // Get the operating system from the parsed user agent

// Check if the operating system matches any of the common mobile operating systems
if(deviceType.match(/Android|iOS|Windows Phone/i)){
Expand Down
2 changes: 0 additions & 2 deletions server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ const storage = multer.diskStorage({
},
});

app.get('/', (req,res) => {})

/* REGISTER ROUTER*/
app.use("/auth", authRouter);

Expand Down
2 changes: 1 addition & 1 deletion server/utils/validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export class Validator {
* @returns {boolean | string}
*/
static async isPassword(value) {
if (!value.trim()) {
if (!value) {
return "Password is required";
}

Expand Down
Loading