Compare commits

...

3 Commits

4 changed files with 41 additions and 13 deletions

View File

@ -37,7 +37,10 @@
"confirm_password": "Confirm Password", "confirm_password": "Confirm Password",
"username": "Username", "username": "Username",
"display_name": "Display Name", "display_name": "Display Name",
"create_account_button": "Create Account!" "create_account_button": "Create Account!",
"login_required_field_blank": "You must enter both a valid email address and password.",
"create_required_field_blank": "You must complete all required fields.",
"create_password_confirm_mismatch": "Both password fields must match."
}, },
"search": { "search": {
"header": "Search", "header": "Search",
@ -62,6 +65,7 @@
"see_book_details": "See Book Details" "see_book_details": "See Book Details"
}, },
"interaction": { "interaction": {
"required": "Required",
"reload": "Reload", "reload": "Reload",
"heart": "Like", "heart": "Like",
"add": "Add to Shelf", "add": "Add to Shelf",
@ -75,6 +79,22 @@
"account_create_invalid_username": "The username entered is not valid. Usernames must be at least 2 characters long and can only contain letters az, numbers 09, and underscores", "account_create_invalid_username": "The username entered is not valid. Usernames must be at least 2 characters long and can only contain letters az, numbers 09, and underscores",
"account_email_exists": "The email address entered is already in use.", "account_email_exists": "The email address entered is already in use.",
"account_username_exists": "The username entered is already in use.", "account_username_exists": "The username entered is already in use.",
"account_create_success": "Account created successfully! You are now logged in." "account_email_send_fail": "Your account was created successfully, but we were unable to send the confirmation email!",
"account_confirm_email": "A confirmation email has been sent to the address you specified. Please confirm your account using the link provided.",
"account_create_success": "Account created successfully! You may now log in using the email address and password you provided.",
"account_confirm_required_data_missing": "Could not confirm account because required data is missing.",
"account_confirm_invalid_code": "The specified confirmation code is not valid.",
"account_confirm_update_fail": "Something went wrong and we couldn't confirm your account. Please try again later!",
"account_confirm_email_send_fail": "Your account has been confirmed, but we were unable to send the email notification about it. You can log in anyway.",
"account_confirm_success_email": "Your account has been confirmed, and an email notification has been sent! You may now log in using your email address and password.",
"account_confirm_success": "Your account has been confirmed! You may now log in using your email address and password.",
"account_login_required_data_missing": "Could not attempt login because required data is missing.",
"account_login_invalid_email": "The email address specified does not have an associated account.",
"account_login_not_confirmed": "The specified account has not been confirmed. Please use the link you received to confirm your email address.",
"account_login_invalid_password": "The password specified is not correct.",
"account_login_success": "You have been successfully logged in! You will now be redirected to the home screen.",
"account_validate_missing_token": "User not logged in: There is no login token to validate.",
"account_validate_invalid_token": "User not logged in: The stored token is not a valid token.",
"account_validate_renewed_token": "User logged in, and the token has been renewed."
} }
} }

View File

@ -48,6 +48,7 @@ export const loginView = (state, emit, i18n) => {
<input type="email" name="email" <input type="email" name="email"
value=${controller.state.fieldValues.loginEmail} value=${controller.state.fieldValues.loginEmail}
oninput=${e => controller.state.fieldValues.loginEmail = e.target.value.trim()} oninput=${e => controller.state.fieldValues.loginEmail = e.target.value.trim()}
onkeyup=${e => { if (e.key === 'Enter') controller.validateLogin() }}
> >
</label> </label>
<label> <label>
@ -55,12 +56,13 @@ export const loginView = (state, emit, i18n) => {
<input type="password" name="password" <input type="password" name="password"
value=${controller.state.fieldValues.loginPassword} value=${controller.state.fieldValues.loginPassword}
oninput=${e => controller.state.fieldValues.loginPassword = e.target.value} oninput=${e => controller.state.fieldValues.loginPassword = e.target.value}
onkeyup=${e => { if (e.key === 'Enter') controller.validateLogin() }}
> >
</label> </label>
${ ${
controller.state.loginError === '' controller.state.loginError === ''
? null ? null
: html`<div class="error card">${controller.state.loginError}</div>` : html`<div class="error card"><header>${controller.state.loginError}</header></div>`
} }
<button ${controller.state.isChecking ? 'disabled' : null} <button ${controller.state.isChecking ? 'disabled' : null}
onclick=${() => controller.validateLogin()} onclick=${() => controller.validateLogin()}
@ -86,31 +88,35 @@ export const loginView = (state, emit, i18n) => {
: html`<div class="success card"><header>${controller.state.createMessage}</header></div>` : html`<div class="success card"><header>${controller.state.createMessage}</header></div>`
} }
<label> <label>
<span>${__('login.email')}</span> <span title=${__('interaction.required')}>${__('login.email')}*</span>
<input type="email" name="new_email" <input type="email" name="new_email" required
value=${controller.state.fieldValues.createEmail} value=${controller.state.fieldValues.createEmail}
oninput=${e => controller.state.fieldValues.createEmail = e.target.value.trim()} oninput=${e => controller.state.fieldValues.createEmail = e.target.value.trim()}
onkeyup=${e => { if (e.key === 'Enter') controller.validateCreateAccount() }}
> >
</label> </label>
<label> <label>
<span>${__('login.password')}</span> <span title=${__('interaction.required')}>${__('login.password')}*</span>
<input type="password" name="new_password" <input type="password" name="new_password" required
value=${controller.state.fieldValues.createPassword} value=${controller.state.fieldValues.createPassword}
oninput=${e => controller.state.fieldValues.createPassword = e.target.value} oninput=${e => controller.state.fieldValues.createPassword = e.target.value}
onkeyup=${e => { if (e.key === 'Enter') controller.validateCreateAccount() }}
> >
</label> </label>
<label> <label>
<span>${__('login.confirm_password')}</span> <span title=${__('interaction.required')}>${__('login.confirm_password')}*</span>
<input type="password" name="confirm_password" <input type="password" name="confirm_password" required
value=${controller.state.fieldValues.createConfirm} value=${controller.state.fieldValues.createConfirm}
oninput=${e => controller.state.fieldValues.createConfirm = e.target.value} oninput=${e => controller.state.fieldValues.createConfirm = e.target.value}
onkeyup=${e => { if (e.key === 'Enter') controller.validateCreateAccount() }}
> >
</label> </label>
<label> <label>
<span>${__('login.username')}</span> <span title=${__('interaction.required')}>${__('login.username')}*</span>
<input type="text" name="new_username" <input type="text" name="new_username" required
value=${controller.state.fieldValues.createUsername} value=${controller.state.fieldValues.createUsername}
oninput=${e => controller.state.fieldValues.createUsername = e.target.value.trim()} oninput=${e => controller.state.fieldValues.createUsername = e.target.value.trim()}
onkeyup=${e => { if (e.key === 'Enter') controller.validateCreateAccount() }}
> >
</label> </label>
<label> <label>
@ -118,6 +124,7 @@ export const loginView = (state, emit, i18n) => {
<input type="text" name="new_displayname" <input type="text" name="new_displayname"
value=${controller.state.fieldValues.createDisplayName} value=${controller.state.fieldValues.createDisplayName}
oninput=${e => controller.state.fieldValues.createDisplayName = e.target.value.trim()} oninput=${e => controller.state.fieldValues.createDisplayName = e.target.value.trim()}
onkeyup=${e => { if (e.key === 'Enter') controller.validateCreateAccount() }}
> >
</label> </label>
${ ${

View File

@ -69,10 +69,11 @@ class Account {
} }
static cleanCreateAccountFormData (formData) { static cleanCreateAccountFormData (formData) {
var displayName = typeof formData.displayName !== 'undefined' ? formData.displayName.toString().trim() : '';
return { return {
email: formData.email.trim(), email: formData.email.trim(),
username: formData.username.toString().trim(), username: formData.username.toString().trim(),
displayName: typeof formData.displayName !== 'undefined' ? formData.displayName.toString().trim() : 'A Bee', displayName: displayName.length > 0 ? displayName : 'A Bee',
password: formData.password, password: formData.password,
} }
} }

View File

@ -30,7 +30,7 @@ function getSequelizeModels (sequelize) {
allowNull: false, allowNull: false,
unique: true, unique: true,
validate: { validate: {
len: [2, 32], len: [1, 32],
}, },
}, },
passwordHash: { passwordHash: {