Skip to content

Commit

Permalink
Merge branch 'main' into closes-issue-SurajPratap10#636
Browse files Browse the repository at this point in the history
Signed-off-by: Abdul Khalid <[email protected]>
  • Loading branch information
0xabdulkhaliq authored Jul 28, 2023
2 parents c1d8862 + c95d733 commit e25218d
Show file tree
Hide file tree
Showing 11 changed files with 535 additions and 416 deletions.
43 changes: 24 additions & 19 deletions controllers/authController.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,28 +61,33 @@ exports.signupController = async (req, res) => {
};

exports.loginController = async (req, res) => {
const { email, password } = req.body;
if (!emailValidator.validate(email)) {
res.status(400).json({ error: "invalid email!!!!" });
return;
}
const user_list = await userModel.find({ email });

if (user_list.length === 0) {
res.status(400).json({ error: "No such Email Exists!!!!" });
return;
} else {
//email is in our DB..let's check for matching password
const user = user_list[0];
const matched = await user.matchPassword(password);
try {
const { email, password } = req.body;
if (!emailValidator.validate(email)) {
res.status(400).json({ error: "invalid email!!!!" });
return;
}
const user_list = await userModel.find({ email });

if (!matched) {
//invalid-password
res.status(400).json({ error: "Invalid Password" });
if (user_list.length === 0) {
res.status(400).json({ error: "No such Email Exists!!!!" });
return;
} else {
//if matched..get the tokens
this.sendToken(user, res);
//email is in our DB..let's check for matching password
const user = user_list[0];
const matched = await user.matchPassword(password);

if (!matched) {
//invalid-password
res.status(400).json({ error: "Invalid Password" });
return;
} else {
//if matched..get the tokens
this.sendToken(user, res);
}
}
} catch (error) {
console.log("Error: " + error);
res.status(500).json({ error: "Someting Went Wrong!!! Try Again" });
}
};
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"express": "^4.18.2",
"express-session": "^1.17.3",
"jsonwebtoken": "^9.0.0",
"mongoose": "^7.4.0",
"mongoose": "^7.4.1",
"openai": "^3.3.0",
"passport": "^0.6.0",
"passport-google-oauth": "^2.0.0",
Expand Down
63 changes: 35 additions & 28 deletions public/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,10 @@ img {

#newsletter .news-form {
display: flex;
width: 40%;
align-items: center;
justify-content: center;
width: 100%;
max-width: 50%;
}

#newsletter .news-form input {
Expand Down Expand Up @@ -1031,17 +1034,16 @@ footer .bottom {

footer .bottom a {
color: yellow !important;
}

footer a {
transition: all 0.3s ease;
}

footer a:hover {
color: #2cceff !important;
}

/* .boxx a:hover {
padding-left: 8px;
} */

.tyfs {
display: block;
margin: 10px 0;
Expand Down Expand Up @@ -1175,13 +1177,6 @@ span {
transform: translate(-50%, -50%);
}

/* --------------- Contact US CSS ---------------- */

/* .Contact-Us {
margin-top: 5%;
display: grid;
} */

.contact-top {
text-align: center;
display: flex;
Expand Down Expand Up @@ -2173,6 +2168,9 @@ button:disabled{
.content .right {
margin-top: 40px;
}
#newsletter{
padding: 20px 10px;
}
}

@media (max-width: 915px) {
Expand All @@ -2184,8 +2182,14 @@ button:disabled{
justify-content: space-between;
}


}

@media (max-width: 768px) {
#newsletter {
height: 22vh;
height: fit-content;
padding: 10px 0;
flex-direction: column;
}

#newsletter .news-text h4 {
Expand All @@ -2197,7 +2201,10 @@ button:disabled{
}

#newsletter .news-form {
width: 45%;
text-align: center;
min-width: 50%;
width: 90%;
max-width: none;
}

#newsletter .news-form input {
Expand All @@ -2209,11 +2216,8 @@ button:disabled{
width: 30%;
text-align: center;
font-size: 10px;
padding: 2px 6px;
margin: auto 0;
}
}

@media (max-width: 768px) {
.contact_us .text-content {
display: none;
}
Expand Down Expand Up @@ -2416,6 +2420,7 @@ button:disabled{
align-items: baseline;
margin: auto;
}

@media (max-width: 648px) {
.wrapper {
justify-content: center;
Expand Down Expand Up @@ -2715,11 +2720,11 @@ button:disabled{
}

#newsletter {
padding: 10px;
padding: 15px;
}

#newsletter .news-text {
width: 50%;
width: 100%;
}

#newsletter .news-text h4 {
Expand All @@ -2730,16 +2735,18 @@ button:disabled{
font-size: 16px;
}

#newsletter .news-form {
width: 48%;
}

#newsletter .news-form input {
padding: 0px 2px;
height: 20px;
width: 50%;
padding: 0px 8px;
font-size: 12px;
}


#news-form{
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
}
#newsletter .news-form button {
font-size: 8px;
padding: 0px 6px;
Expand Down Expand Up @@ -2865,4 +2872,4 @@ section .container2 {
.upper img {
width: 100px;
margin-bottom: 20px;
}
}
20 changes: 5 additions & 15 deletions public/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,6 @@ window.addEventListener("load", function () {
loader.style.display = "none";
});

const popup = document.getElementById("popup");

function closePopUp() {
popup.classList.remove("open-popup");
}

function openPopUp(text) {
document.getElementById("text").innerHTML = text;
popup.classList.add("open-popup");
}

function onSubmit(e) {
if (window.location.href == "/signup" || window.location.href == "/login") {
return false;
Expand All @@ -36,17 +25,18 @@ function onSubmit(e) {
switch (true) {
case prompt === "":
text = "Please add some text";
openPopUp(text);
// alert(text);
toastr["warning"](text, "Validation");
return;

case API_KEY === "":
text = "Please add your API Key";
openPopUp(text); //if API Key is not added
toastr["warning"](text, "Validation");
return;

case !apiRegex.test(API_KEY):
text = "Please add correct API Key";
openPopUp(text); //if API Key is not added
toastr["warning"](text, "Validation");
return;
}

Expand Down Expand Up @@ -204,7 +194,7 @@ async function generateImageRequest(prompt, API_KEY, size, numImages) {
// hideLoading();
removeSpinner();
} catch (error) {
openPopUp(error);
console.log(error);
return error;
}
}
Expand Down
4 changes: 3 additions & 1 deletion views/imagineAi.ejs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<%- include('includes/PRE.ejs') %>
<%- include('includes/sidebar.ejs') %>
<%- include('includes/header.ejs') %>
</head>
<%- include('includes/navbar.ejs') %>
<%- include('includes/sidebar.ejs') %>
<%- include('alan.ejs') %>
<main>
<section class="showcase" id="showcase">
Expand Down Expand Up @@ -62,7 +64,7 @@
</form>
</section>
<section class="image">
<div class="image-container">
<div id="image-container" class="grid grid-cols-2 md:grid-cols-3 gap-4">
<h2 class="msg"></h2>
<img src="" alt="" id="image"/>
</div>
Expand Down
1 change: 1 addition & 0 deletions views/includes/header.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
<link rel="stylesheet" href="css/spinner.css" />
<link rel="stylesheet" href="css/vanilla-toast.css" />
<link rel="stylesheet" type="text/css" href="css/toastr.min.css" />
<script src="https://cdn.tailwindcss.com"></script>

<script src="js/main.js" defer></script>
<script src="js/signup.js" defer></script>
Expand Down
9 changes: 7 additions & 2 deletions views/includes/navbar.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,14 @@
width: 100%;
}
/* Light mode styles */
.AI {
display: inline-block;
padding: 10px;
margin-left: 25px;
}
/* Light mode styles
.light-mode {
}
} */
/* Dark mode styles */
.dark-mode {
Expand Down
10 changes: 8 additions & 2 deletions views/includes/sidebar.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,13 @@
font-size: 40px;
width: 50px;
display: none;
}
}
.hamburger i{
padding: 5px 10px;
background-color: whitesmoke;
border-radius: 10px;
}
@media (max-width:900px){
.hamburger{
Expand Down Expand Up @@ -101,4 +107,4 @@ const hamburgere1=document.querySelector(".hamburger");
sidebarE1.style.setProperty('transform', 'translateX(100%)');
}
</script>
</script>
2 changes: 1 addition & 1 deletion views/login.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -175,4 +175,4 @@
}
}
</script>
</script>
Loading

0 comments on commit e25218d

Please sign in to comment.