|
@@ -1,108 +1,143 @@
|
|
|
<template>
|
|
|
- <div class="modal is-active">
|
|
|
- <div
|
|
|
- class="modal-background"
|
|
|
- @click="
|
|
|
- closeModal({
|
|
|
- sector: 'header',
|
|
|
- modal: 'register'
|
|
|
- })
|
|
|
- "
|
|
|
- />
|
|
|
- <div class="modal-card">
|
|
|
- <header class="modal-card-head">
|
|
|
- <p class="modal-card-title">Register</p>
|
|
|
- <button
|
|
|
- class="delete"
|
|
|
- @click="
|
|
|
- closeModal({
|
|
|
- sector: 'header',
|
|
|
- modal: 'register'
|
|
|
- })
|
|
|
- "
|
|
|
- />
|
|
|
- </header>
|
|
|
- <section class="modal-card-body">
|
|
|
- <p class="control">
|
|
|
- <label class="label">Email</label>
|
|
|
- <input
|
|
|
- v-model="email.value"
|
|
|
- class="input"
|
|
|
- type="email"
|
|
|
- placeholder="Email..."
|
|
|
- @blur="onInputBlur('email')"
|
|
|
- autofocus
|
|
|
+ <div>
|
|
|
+ <metadata title="Register" v-if="isPage" />
|
|
|
+ <div class="modal is-active">
|
|
|
+ <div class="modal-background" @click="closeRegisterModal()" />
|
|
|
+ <div class="modal-card">
|
|
|
+ <header class="modal-card-head">
|
|
|
+ <p class="modal-card-title">Register</p>
|
|
|
+ <button
|
|
|
+ v-if="!isPage"
|
|
|
+ class="delete"
|
|
|
+ @click="closeRegisterModal()"
|
|
|
/>
|
|
|
- </p>
|
|
|
- <transition name="fadein-helpbox">
|
|
|
- <input-help-box
|
|
|
- v-if="email.entered"
|
|
|
- :valid="email.valid"
|
|
|
- :message="email.message"
|
|
|
- ></input-help-box>
|
|
|
- </transition>
|
|
|
+ </header>
|
|
|
+ <section class="modal-card-body">
|
|
|
+ <!-- email address -->
|
|
|
+ <p class="control">
|
|
|
+ <label class="label">Email</label>
|
|
|
+ <input
|
|
|
+ v-model="email.value"
|
|
|
+ class="input"
|
|
|
+ type="email"
|
|
|
+ placeholder="Email..."
|
|
|
+ @keypress="onInput('email')"
|
|
|
+ autofocus
|
|
|
+ />
|
|
|
+ </p>
|
|
|
+ <transition name="fadein-helpbox">
|
|
|
+ <input-help-box
|
|
|
+ :entered="email.entered"
|
|
|
+ :valid="email.valid"
|
|
|
+ :message="email.message"
|
|
|
+ ></input-help-box>
|
|
|
+ </transition>
|
|
|
|
|
|
- <p class="control">
|
|
|
- <label class="label">Username</label>
|
|
|
- <input
|
|
|
- v-model="username.value"
|
|
|
- class="input"
|
|
|
- type="text"
|
|
|
- placeholder="Username..."
|
|
|
- @blur="onInputBlur('username')"
|
|
|
- />
|
|
|
- </p>
|
|
|
- <transition name="fadein-helpbox">
|
|
|
- <input-help-box
|
|
|
- v-if="username.entered"
|
|
|
- :valid="username.valid"
|
|
|
- :message="username.message"
|
|
|
- ></input-help-box>
|
|
|
- </transition>
|
|
|
+ <!-- username -->
|
|
|
+ <p class="control">
|
|
|
+ <label class="label">Username</label>
|
|
|
+ <input
|
|
|
+ v-model="username.value"
|
|
|
+ class="input"
|
|
|
+ type="text"
|
|
|
+ placeholder="Username..."
|
|
|
+ @keypress="onInput('username')"
|
|
|
+ />
|
|
|
+ </p>
|
|
|
+ <transition name="fadein-helpbox">
|
|
|
+ <input-help-box
|
|
|
+ :entered="username.entered"
|
|
|
+ :valid="username.valid"
|
|
|
+ :message="username.message"
|
|
|
+ ></input-help-box>
|
|
|
+ </transition>
|
|
|
|
|
|
- <p class="control">
|
|
|
- <label class="label">Password</label>
|
|
|
- <input
|
|
|
- v-model="password.value"
|
|
|
- class="input"
|
|
|
- type="password"
|
|
|
- placeholder="Password..."
|
|
|
- @blur="onInputBlur('password')"
|
|
|
- @keypress="$parent.submitOnEnter(submitModal, $event)"
|
|
|
- />
|
|
|
- </p>
|
|
|
- <transition name="fadein-helpbox">
|
|
|
- <input-help-box
|
|
|
- v-if="password.entered"
|
|
|
- :valid="password.valid"
|
|
|
- :message="password.message"
|
|
|
- ></input-help-box>
|
|
|
- </transition>
|
|
|
+ <!-- password -->
|
|
|
+ <p class="control">
|
|
|
+ <label class="label">Password</label>
|
|
|
+ </p>
|
|
|
+
|
|
|
+ <div id="password-container">
|
|
|
+ <input
|
|
|
+ v-model="password.value"
|
|
|
+ class="input"
|
|
|
+ type="password"
|
|
|
+ ref="password"
|
|
|
+ placeholder="Password..."
|
|
|
+ @keypress="
|
|
|
+ onInput('password') &&
|
|
|
+ $parent.submitOnEnter(submitModal, $event)
|
|
|
+ "
|
|
|
+ />
|
|
|
+ <a @click="togglePasswordVisibility()">
|
|
|
+ <i class="material-icons">
|
|
|
+ {{
|
|
|
+ !password.visible
|
|
|
+ ? "visibility"
|
|
|
+ : "visibility_off"
|
|
|
+ }}
|
|
|
+ </i>
|
|
|
+ </a>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <transition name="fadein-helpbox">
|
|
|
+ <input-help-box
|
|
|
+ :valid="password.valid"
|
|
|
+ :entered="password.entered"
|
|
|
+ :message="password.message"
|
|
|
+ ></input-help-box>
|
|
|
+ </transition>
|
|
|
|
|
|
- <br />
|
|
|
+ <br />
|
|
|
|
|
|
- <p>
|
|
|
- By logging in/registering you agree to our
|
|
|
- <router-link to="/terms"> Terms of Service </router-link
|
|
|
- > and
|
|
|
- <router-link to="/privacy"> Privacy Policy </router-link>.
|
|
|
- </p>
|
|
|
- </section>
|
|
|
- <footer class="modal-card-foot">
|
|
|
- <a class="button is-primary" href="#" @click="submitModal()"
|
|
|
- >Submit</a
|
|
|
- >
|
|
|
- <a
|
|
|
- class="button is-github"
|
|
|
- :href="apiDomain + '/auth/github/authorize'"
|
|
|
- @click="githubRedirect()"
|
|
|
- >
|
|
|
- <div class="icon">
|
|
|
- <img class="invert" src="/assets/social/github.svg" />
|
|
|
+ <p>
|
|
|
+ By registering you agree to our
|
|
|
+ <router-link
|
|
|
+ to="/terms"
|
|
|
+ @click.native="closeRegisterModal()"
|
|
|
+ >
|
|
|
+ Terms of Service
|
|
|
+ </router-link>
|
|
|
+ and
|
|
|
+ <router-link
|
|
|
+ to="/privacy"
|
|
|
+ @click.native="closeRegisterModal()"
|
|
|
+ >
|
|
|
+ Privacy Policy </router-link
|
|
|
+ >.
|
|
|
+ </p>
|
|
|
+ </section>
|
|
|
+ <footer class="modal-card-foot">
|
|
|
+ <router-link to="/login" v-if="isPage">
|
|
|
+ Already have an account?
|
|
|
+ </router-link>
|
|
|
+ <a v-else href="#" @click="changeToLoginModal()">
|
|
|
+ Already have an account?
|
|
|
+ </a>
|
|
|
+
|
|
|
+ <div id="actions">
|
|
|
+ <a
|
|
|
+ class="button is-github"
|
|
|
+ :href="apiDomain + '/auth/github/authorize'"
|
|
|
+ @click="githubRedirect()"
|
|
|
+ >
|
|
|
+ <div class="icon">
|
|
|
+ <img
|
|
|
+ class="invert"
|
|
|
+ src="/assets/social/github.svg"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ Register with GitHub
|
|
|
+ </a>
|
|
|
+ <a
|
|
|
+ class="button is-primary"
|
|
|
+ href="#"
|
|
|
+ @click="submitModal()"
|
|
|
+ >Register</a
|
|
|
+ >
|
|
|
</div>
|
|
|
- Register with GitHub
|
|
|
- </a>
|
|
|
- </footer>
|
|
|
+ </footer>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</template>
|
|
@@ -122,7 +157,7 @@ export default {
|
|
|
value: "",
|
|
|
valid: false,
|
|
|
entered: false,
|
|
|
- message: "Please enter a valid username."
|
|
|
+ message: "Only letters, numbers and underscores are allowed."
|
|
|
},
|
|
|
email: {
|
|
|
value: "",
|
|
@@ -134,14 +169,17 @@ export default {
|
|
|
value: "",
|
|
|
valid: false,
|
|
|
entered: false,
|
|
|
- message: "Please enter a valid password."
|
|
|
+ visible: false,
|
|
|
+ message:
|
|
|
+ "Include at least one lowercase letter, one uppercase letter, one number and one special character."
|
|
|
},
|
|
|
recaptcha: {
|
|
|
key: "",
|
|
|
token: "",
|
|
|
enabled: false
|
|
|
},
|
|
|
- apiDomain: ""
|
|
|
+ apiDomain: "",
|
|
|
+ isPage: false
|
|
|
};
|
|
|
},
|
|
|
watch: {
|
|
@@ -153,7 +191,7 @@ export default {
|
|
|
this.username.valid = false;
|
|
|
} else if (!validation.regex.azAZ09_.test(value)) {
|
|
|
this.username.message =
|
|
|
- "Invalid username format. Allowed characters: a-z, A-Z, 0-9 and _.";
|
|
|
+ "Invalid format. Allowed characters: a-z, A-Z, 0-9 and _.";
|
|
|
this.username.valid = false;
|
|
|
} else {
|
|
|
this.username.message = "Everything looks great!";
|
|
@@ -170,7 +208,7 @@ export default {
|
|
|
value.indexOf("@") !== value.lastIndexOf("@") ||
|
|
|
!validation.regex.emailSimple.test(value)
|
|
|
) {
|
|
|
- this.email.message = "Invalid Email format.";
|
|
|
+ this.email.message = "Invalid format.";
|
|
|
this.email.valid = false;
|
|
|
} else {
|
|
|
this.email.message = "Everything looks great!";
|
|
@@ -185,7 +223,7 @@ export default {
|
|
|
this.password.valid = false;
|
|
|
} else if (!validation.regex.password.test(value)) {
|
|
|
this.password.message =
|
|
|
- "Invalid password format. Must have one lowercase letter, one uppercase letter, one number and one special character.";
|
|
|
+ "Include at least one lowercase letter, one uppercase letter, one number and one special character.";
|
|
|
this.password.valid = false;
|
|
|
} else {
|
|
|
this.password.message = "Everything looks great!";
|
|
@@ -194,6 +232,8 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
async mounted() {
|
|
|
+ if (this.$route.path === "/register") this.isPage = true;
|
|
|
+
|
|
|
this.apiDomain = await lofig.get("apiDomain");
|
|
|
|
|
|
lofig.get("recaptcha").then(obj => {
|
|
@@ -221,6 +261,25 @@ export default {
|
|
|
});
|
|
|
},
|
|
|
methods: {
|
|
|
+ togglePasswordVisibility() {
|
|
|
+ if (this.$refs.password.type === "password") {
|
|
|
+ this.$refs.password.type = "text";
|
|
|
+ this.password.visible = true;
|
|
|
+ } else {
|
|
|
+ this.$refs.password.type = "password";
|
|
|
+ this.password.visible = false;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ changeToLoginModal() {
|
|
|
+ if (!this.isPage) {
|
|
|
+ this.closeRegisterModal();
|
|
|
+ this.openModal({ sector: "header", modal: "login" });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ closeRegisterModal() {
|
|
|
+ if (!this.isPage)
|
|
|
+ this.closeModal({ sector: "header", modal: "login" });
|
|
|
+ },
|
|
|
submitModal() {
|
|
|
if (
|
|
|
!this.username.valid ||
|
|
@@ -240,13 +299,13 @@ export default {
|
|
|
})
|
|
|
.catch(err => new Toast(err.message));
|
|
|
},
|
|
|
- onInputBlur(inputName) {
|
|
|
+ onInput(inputName) {
|
|
|
this[inputName].entered = true;
|
|
|
},
|
|
|
githubRedirect() {
|
|
|
localStorage.setItem("github_redirect", this.$route.path);
|
|
|
},
|
|
|
- ...mapActions("modalVisibility", ["closeModal"]),
|
|
|
+ ...mapActions("modalVisibility", ["closeModal", "openModal"]),
|
|
|
...mapActions("user/auth", ["register"])
|
|
|
}
|
|
|
};
|
|
@@ -267,6 +326,30 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+#password-container {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+
|
|
|
+ a {
|
|
|
+ width: 0;
|
|
|
+ margin-left: -30px;
|
|
|
+ z-index: 0;
|
|
|
+ top: 2px;
|
|
|
+ position: relative;
|
|
|
+ color: var(--light-grey-1);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+.control {
|
|
|
+ margin-bottom: 2px !important;
|
|
|
+}
|
|
|
+
|
|
|
+.modal-card-foot {
|
|
|
+ display: flex;
|
|
|
+ justify-content: space-between;
|
|
|
+ flex-wrap: wrap;
|
|
|
+}
|
|
|
+
|
|
|
.button.is-github {
|
|
|
background-color: var(--dark-grey-2);
|
|
|
color: var(--white) !important;
|