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

Displaying value fields in edit profile #160

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
4 changes: 3 additions & 1 deletion controls/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,9 @@ exports.submission_subID = async (req, res, next) => {
* route: /user/updateProfile
*/
exports.getUpdateProfile = (req, res, next) => {
res.render("edit_profile", { message: null });
user.findById(req.params.id, (err, data) => {
res.render("edit_profile", { 'data' : data });
})
}

/**Updating the user info i.e. email, name and password
Expand Down
2 changes: 1 addition & 1 deletion routes/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ router.get("/submissions", enforceAuthentication(true, false), authController.su
router.get("/submission/:subID", enforceAuthentication(true, false), authController.submission_subID);

/**Display the user update profile page */
router.get("/updateProfile", enforceAuthentication(true, false), authController.getUpdateProfile);
router.get("/updateProfile/:id", enforceAuthentication(true, false), authController.getUpdateProfile);

/**POST: user profile update */
router.post("/updateProfile", enforceAuthentication(true, false), authController.postUpdateProfile);
Expand Down
4 changes: 2 additions & 2 deletions views/edit_profile.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@
<div class="field">
<p class="control">
Name
<input class="input" name="name" type="text" placeholder="Name">
<input class="input" name="name" type="text" placeholder="Name" value=<%= data.name %>>
</p>
</div>
<div class="field">
<p class="control">
Email
<input class="input" name="email" type="email" placeholder="Email">
<input class="input" name="email" type="email" placeholder="Email" value=<%= data.email %>>
</p>
<p class="control">
<button class="button is-info">Save Changes</button>
Expand Down
2 changes: 1 addition & 1 deletion views/profile.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
[ <a href="/user/submissions">My submission history</a> ]
</p>
<p>
[ <a href="/user/updateProfile">Update Profile</a> ]
[ <a href="/user/updateProfile/<%= locals.user.id %>">Update Profile</a> ]
</p>
</div>
<div id="submissions-chart"></div>
Expand Down