Skip to content

Commit d8b4724

Browse files
commit fixes
1 parent bbc2700 commit d8b4724

File tree

6 files changed

+35
-17
lines changed

6 files changed

+35
-17
lines changed

public/auth.page.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,19 @@ function onSignUpSubmit(event) {
2020
HTTP.signupUser({
2121
userData,
2222
onSuccess: user => {
23-
alert(`User "${user.username}" created, you may now log in.`);
23+
24+
$('.alert').html(`User "${user.username}" created, you may now log in.`);
2425
window.open('/login.html', '_self');
2526
},
2627
onError: err => {
27-
alert('There was a problem processing your request, please try again later.');
28+
$('.alert').html('A user with that username and/or email already exists.')
29+
2830

2931
}
3032
});
3133
}
3234

3335
function onLoginSubmit(event) {
34-
console.log("OnLogin Running")
3536

3637
event.preventDefault();
3738
const userData = {
@@ -46,11 +47,11 @@ function onLoginSubmit(event) {
4647
authenticatedUser.jwtToken = response.jwtToken;
4748
CACHE.saveAuthenticatedUserIntoCache(authenticatedUser);
4849

49-
alert('Login succesful, redirecting you to homepage ...');
50+
$('.alert').html('Login succesful, redirecting you to homepage ...');
5051
window.open('/home.html', '_self');
5152
},
5253
onError: err => {
53-
alert('Incorrect username or password. Please try again.');
54+
$('.alert').html('Incorrect username or password. Please try again.');
5455
}
5556
});
5657
}

public/css/main.css

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -963,4 +963,20 @@ input[type=number]::-webkit-outer-spin-button {
963963
.wo-container {
964964
width: 320px;
965965
}
966+
}
967+
968+
969+
/* INVALID FORMS */
970+
971+
input:required:invalid {
972+
border-color: #C00000;
973+
}
974+
975+
.labels {
976+
text-align: left;
977+
font-size: 2rem;
978+
}
979+
980+
.alert {
981+
color: #C00000
966982
}

public/home.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,13 @@ function onWorkoutCardClick(event) {
3636

3737
// Handle deleting Workouts
3838
function onDeleteWorkoutBtnClick(event) {
39-
/**
40-
* Because "onWorkoutDeleteClick" and "onWorkoutClick" both are listening for clicks inside of
41-
* #Workout-card element, we need to call event.stopImmediatePropagation to avoid both
42-
* event listeners firing when we click on the delete button inside #Workout-card.
43-
*/
39+
4440
event.stopImmediatePropagation();
45-
// Step 1: Get the Workout id to delete from it's parent.
4641
const workoutId = $(event.currentTarget)
4742
.closest('#workout-card')
4843
.attr('data-workout-id');
49-
// Step 2: Verify use is sure of deletion
5044
const userSaidYes = confirm('Are you sure you want to delete this workout?');
5145
if (userSaidYes) {
52-
// Step 3: Make ajax call to delete workout
5346
HTTP.deleteWorkout({
5447
workoutId: workoutId,
5548
jwtToken: STATE.authUser.jwtToken,

public/login.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ <h1>Sign into your account</h1>
3333
<p class="message"> Not registered?
3434
<a class="js-signUp" href="/signup.html">Create an account </a>
3535
</p>
36+
<h4 class="alert"></h4>
3637
</div>
3738

3839
</div>

public/signup.html

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,19 @@ <h1 class="log-logo">
2828

2929
<h1>Create Free Account</h1>
3030
<form id="sign-up-form" class="signup-form" action="/api/user" method="POST">
31+
<label class="labels" for="name">Name</labelclass>
32+
<input class="item" id="name-txt" type="text" placeholder="name" name="name" autocomplete="off" pattern=".{4,}" title="4 Characters min." required/>
3133

32-
<input class="item" id="name-txt" type="text" placeholder="name" name="name" autocomplete="off" required/>
34+
<label class="labels" for="username">Username</label>
3335
<input class="item" id="username-txt" type="text" placeholder="username" name="username" autocomplete="off" required/>
36+
<label class="labels" for="password">Password</label>
3437
<input class="item" id="password-txt" type="password" placeholder="password" name="password" autocomplete="off" pattern="(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,}" title="Must contain at least one number and one uppercase and lowercase letter, and at least 8 or more characters"
3538
required/>
36-
<input class="item" id="email-txt" type="text" placeholder="email address" name="email" autocomplete="off" />
37-
<button class="login-btn" type="submit">Register</button>
38-
<p class="message">Already registered? <a href="./login.html">Sign In</a></p>
39+
<labelclass="labels" for="email">E-mail</label>
40+
<input class="item" id="email-txt" type="text" placeholder="email address" name="email" autocomplete="off" />
41+
<button class="login-btn" type="submit">Register</button>
42+
<p class="message">Already registered? <a href="./login.html">Sign In</a></p>
43+
<h4 class="alert"></h4>
3944
</form>
4045
</div>
4146
</div>

public/utilities/cache.module.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,6 @@ function deleteAuthenticatedUserFromCache() {
3838
localStorage.removeItem('username');
3939
localStorage.removeItem('name');
4040
localStorage.removeItem('email');
41+
localStorage.removeItem('currentDate');
42+
localStorage.removeItem('dateString');
4143
}

0 commit comments

Comments
 (0)