mirror of
https://github.com/TeamPiped/Piped.git
synced 2024-08-14 23:57:27 +00:00
Use regex to check for email on RegisterPage
This commit is contained in:
parent
74c0795248
commit
66913818b4
2 changed files with 11 additions and 1 deletions
|
@ -33,6 +33,8 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import { isEmail } from "../utils/Misc.js";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
@ -52,7 +54,7 @@ export default {
|
||||||
methods: {
|
methods: {
|
||||||
register() {
|
register() {
|
||||||
if (!this.username || !this.password) return;
|
if (!this.username || !this.password) return;
|
||||||
if (this.username.includes("@") && !confirm(this.$t("info.register_no_email_note"))) return;
|
if (isEmail(this.username) && !confirm(this.$t("info.register_no_email_note"))) return;
|
||||||
|
|
||||||
this.fetchJson(this.authApiUrl() + "/register", null, {
|
this.fetchJson(this.authApiUrl() + "/register", null, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
|
|
8
src/utils/Misc.js
Normal file
8
src/utils/Misc.js
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
export const isEmail = input => {
|
||||||
|
// Taken from https://emailregex.com
|
||||||
|
const result = input.match(
|
||||||
|
//eslint-disable-next-line
|
||||||
|
/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,
|
||||||
|
);
|
||||||
|
return result;
|
||||||
|
};
|
Loading…
Reference in a new issue