typo correction
[KisSync.git] / templates / account-edit.pug
blob2882cfbd3d9254a6b08006b4d79c46f28f5c930f
1 extends layout.pug
3 block content
4   if !loggedIn
5     .col-lg-6.col-lg-offset-3.col-md-6.col-md-offset-3
6       .alert.alert-danger.messagebox.center
7         strong Authorization Required
8         p You must be <a href="/login">logged in</a> to view this page.
9   else
10     .col-lg-6.col-lg-offset-3.col-md-6.col-md-offset-3
11       if successMessage
12         .alert.alert-success.center
13           p= successMessage
14       else if errorMessage
15         .alert.alert-danger.center
16           p= errorMessage
17       h3 Change Password
18       form(action="/account/edit", method="post", onsubmit="return validatePasswordChange()")
19         input(type="hidden", name="_csrf", value=csrfToken)
20         input(type="hidden", name="action", value="change_password")
21         .form-group
22           label.control-label(for="username") Username
23           input#username.form-control(type="text", name="name", value=loginName, disabled=true)
24         .form-group
25           label.control-label(for="oldpassword") Current Password
26           input#oldpassword.form-control(type="password", name="oldpassword")
27         .form-group
28           label.control-label(for="newpassword") New Password
29           input#newpassword.form-control(type="password", name="newpassword")
30         .form-group
31           label.control-label(for="newpassword_confirm") Confirm New Password
32           input#newpassword_confirm.form-control(type="password", name="newpassword_confirm")
33         button#changepassbtn.btn.btn-danger.btn-block(type="submit") Change Password
34       hr
35       h3 Change Email
36       form(action="/account/edit", method="post", onsubmit="return submitEmail()")
37         input(type="hidden", name="_csrf", value=csrfToken)
38         input(type="hidden", name="action", value="change_email")
39         .form-group
40           label.control-label(for="username2") Username
41           input#username2.form-control(type="text", name="name", value=loginName, disabled=true)
42         .form-group
43           label.control-label(for="password2") Password
44           input#password2.form-control(type="password", name="password")
45         .form-group
46           label.control-label(for="email") New Email
47           input#email.form-control(type="email", name="email")
48         button#changeemailbtn.btn.btn-danger.btn-block(type="submit") Change Email
50 append footer
51   script(type="text/javascript").
52     function validatePasswordChange() {
53       var pw = $("#newpassword").val();
54       var pwc = $("#newpassword_confirm").val();
55       $("#passwordempty").remove();
56       $("#passwordmismatch").remove();
58       if (pw === '') {
59         $("#newpassword").parent().addClass("has-error");
60         $("<p/>").addClass("text-danger")
61           .attr("id", "passwordempty")
62           .text("Password must not be empty")
63           .insertAfter($("#newpassword"));
64         return false;
65       } else {
66         if (pw !== pwc) {
67           $("#newpassword_confirm").parent().addClass("has-error");
68           $("#newpassword").parent().addClass("has-error");
69           $("<p/>").addClass("text-danger")
70             .attr("id", "passwordmismatch")
71             .text("Passwords do not match")
72             .insertAfter($("#newpassword_confirm"));
73           return false;
74         } else {
75           $("#username").attr("disabled", false);
76           return true;
77         }
78       }
79     }
80     function submitEmail() {
81       $("#username2").attr("disabled", false);
82       return true;
83     }