Skip to content

Commit

Permalink
Added more password validation to account creation
Browse files Browse the repository at this point in the history
  • Loading branch information
elrumo committed May 12, 2021
1 parent f18523b commit 83c46ad
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 40 deletions.
2 changes: 1 addition & 1 deletion website/macos-big-sur-icons/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<script src="//instant.page/5.1.0" type="module" integrity="sha384-by67kQnR+pyfy8yWP4kPO12fHKRLHZPfEsiSXR8u2IKcTdxD805MGUXBzVPnkLHw"></script>

<!-- Apple Login -->
<script type="text/javascript" src="https://appleid.cdn-apple.com/appleauth/static/jsapi/appleid/1/en_US/appleid.auth.js"></script>
<!-- <script type="text/javascript" src="https://appleid.cdn-apple.com/appleauth/static/jsapi/appleid/1/en_US/appleid.auth.js"></script> -->

</head>

Expand Down
107 changes: 68 additions & 39 deletions website/macos-big-sur-icons/src/components/LoginDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,26 @@
name="password"
autocomplete="current-password"
v-on:keyup="getTextFieldValue($event, 'password', false)"
v-on:change="getTextFieldValue($event, 'password', false)"
>
<p class="coral-Body--XS opacity-60 f-w-400 p-t-10">
Password must contain a number, a capital letter and be more than 6 characters long.
</p>
<p v-if="userInfo.step == 2 && userInfo.hasLoggedIn" class="coral-Body--XS opacity-60 f-w-400 p-t-10">
Problems signing in? <span @click="resetPassword" class="coral-link">Reset password</span>
</p>
<div v-if="!userInfo.problems.passNotSecure">
<p class="coral-Body--XS opacity-60 f-w-400 p-t-10">
Password must contain a number, a capital letter and be more than 6 characters long.
</p>
<p v-if="userInfo.step == 2 && userInfo.hasLoggedIn" class="coral-Body--XS opacity-60 f-w-400 p-t-10">
Problems signing in? <a @click="resetPassword" class="coral-link">Reset password</a>
</p>
</div>

<coral-alert
v-if="userInfo.problems.passNotSecure"
style="padding: 10px; margin-top: 15px"
variant="warning"
>
<coral-alert-header>Password not secure enough</coral-alert-header>
<coral-alert-content>
Password must contain a number, a capital letter and be more than 6 characters long.
</coral-alert-content>
</coral-alert>
<!-- <coral-alert
style="padding: 10px; margin-top: 15px"
>
Expand Down Expand Up @@ -276,7 +288,7 @@
<script>
import { mapActions, mapGetters } from 'vuex';
import Parse from 'parse'
import jwt_decode from 'jwt-decode';
// import jwt_decode from 'jwt-decode';
Parse.initialize("macOSicons");
Parse.serverURL = 'https://media.macosicons.com/parse'
Expand Down Expand Up @@ -310,7 +322,8 @@ export default {
isValid: false,
step: 1,
problems:{
usernameExists: false
usernameExists: false,
passNotSecure: false
},
passwordResetSent: false,
Expand All @@ -330,40 +343,40 @@ export default {
this.userInfo.step = step
},
async appleLogin(){
let parent = this;
// async appleLogin(){
// let parent = this;
const userToLogin = new Parse.User();
// const userToLogin = new Parse.User();
console.log("decodedIdToken: ", decodedIdToken);
// console.log("decodedIdToken: ", decodedIdToken);
let appleEmail = decodedIdToken.email
let appleId = decodedIdToken.sub
let token = decodedIdToken.token
// let appleEmail = decodedIdToken.email
// let appleId = decodedIdToken.sub
// let token = decodedIdToken.token
// const response = await window.AppleID.auth.signIn();
// const decodedIdToken = jwt_decode(response.authorization.id_token);
// let appleEmail = decodedIdToken.email
// let appleId = decodedIdToken.sub
// let token = response.authorization.id_token
let authData = {
id: appleId,
email: appleEmail,
token: token
}
await userToLogin.linkWith('apple', {
authData: authData
})
.then(async (loggedInUser) =>{
parent.setUser(JSON.parse(JSON.stringify(loggedInUser)))
userToLogin.set("email", authData.email)
userToLogin.save()
}).catch((error) => {
console.log(error);
})
// // const response = await window.AppleID.auth.signIn();
// // const decodedIdToken = jwt_decode(response.authorization.id_token);
// // let appleEmail = decodedIdToken.email
// // let appleId = decodedIdToken.sub
// // let token = response.authorization.id_token
// let authData = {
// id: appleId,
// email: appleEmail,
// token: token
// }
// await userToLogin.linkWith('apple', {
// authData: authData
// })
// .then(async (loggedInUser) =>{
// parent.setUser(JSON.parse(JSON.stringify(loggedInUser)))
// userToLogin.set("email", authData.email)
// userToLogin.save()
// }).catch((error) => {
// console.log(error);
// })
},
// },
closeDialog(id){
document.getElementById(id).hide()
Expand All @@ -381,16 +394,23 @@ export default {
getTextFieldValue(e, field, isEmail){
let parent = this
let target = e.target
let fieldValue = e.target.value
var isValid = e.target.checkValidity()
// Checks if email has a '.'
if (!fieldValue.includes(".") && isEmail) {
isValid = false
}
parent.userInfo[field] = fieldValue
parent.userInfo.isValid = isValid
if (target.type == "password") {
let passIsValid = !parent.validatePassword
console.log(passIsValid, ": ", parent.userInfo.password);
if(passIsValid) parent.userInfo.problems.passNotSecure = false;
}
},
toArray(obj){
Expand Down Expand Up @@ -480,6 +500,15 @@ export default {
}).catch((error)=>{
parent.isLoading = false
if (error.code == 202) {
parent.showToast({
id: "toastMessage",
message: "Username already in use",
variant: "error"
})
}
if (error.code == 142) {
parent.userInfo.problems.passNotSecure = true
parent.showToast({
id: "toastMessage",
message: "Password must be more secure, see above for details",
Expand Down
4 changes: 4 additions & 0 deletions website/macos-big-sur-icons/src/components/app.less
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ main{
height: 100%;
}

._coral-Alert-icon{
top: 10px;
}

.support-page{
margin: auto !important;
position: relative !important;
Expand Down

1 comment on commit 83c46ad

@vercel
Copy link

@vercel vercel bot commented on 83c46ad May 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.