mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 07:07:35 +01:00
lint common
This commit is contained in:
@@ -558,176 +558,176 @@
|
||||
</style>
|
||||
|
||||
<script>
|
||||
import hello from 'hellojs';
|
||||
import debounce from 'lodash/debounce';
|
||||
import isEmail from 'validator/lib/isEmail';
|
||||
import googlePlay from '@/assets/images/home/google-play-badge.svg';
|
||||
import iosAppStore from '@/assets/images/home/ios-app-store.svg';
|
||||
import iphones from '@/assets/images/home/iphones.svg';
|
||||
import spacer from '@/assets/images/home/spacer.svg';
|
||||
import pixelHorizontal from '@/assets/images/home/pixel-horizontal.svg';
|
||||
import pixelHorizontal2 from '@/assets/images/home/pixel-horizontal-2.svg';
|
||||
import pixelHorizontal3 from '@/assets/images/home/pixel-horizontal-3.svg';
|
||||
import facebookSquareIcon from '@/assets/svg/facebook-square.svg';
|
||||
import googleIcon from '@/assets/svg/google.svg';
|
||||
import cnet from '@/assets/svg/cnet.svg';
|
||||
import fastCompany from '@/assets/svg/fast-company.svg';
|
||||
import discover from '@/assets/images/home/discover.svg';
|
||||
import forbes from '@/assets/images/home/forbes.svg';
|
||||
import kickstarter from '@/assets/images/home/kickstarter.svg';
|
||||
import lifehacker from '@/assets/images/home/lifehacker.svg';
|
||||
import makeuseof from '@/assets/images/home/make-use-of.svg';
|
||||
import thenewyorktimes from '@/assets/images/home/the-new-york-times.svg';
|
||||
import * as Analytics from '@/libs/analytics';
|
||||
import hello from 'hellojs';
|
||||
import debounce from 'lodash/debounce';
|
||||
import isEmail from 'validator/lib/isEmail';
|
||||
import googlePlay from '@/assets/images/home/google-play-badge.svg';
|
||||
import iosAppStore from '@/assets/images/home/ios-app-store.svg';
|
||||
import iphones from '@/assets/images/home/iphones.svg';
|
||||
import spacer from '@/assets/images/home/spacer.svg';
|
||||
import pixelHorizontal from '@/assets/images/home/pixel-horizontal.svg';
|
||||
import pixelHorizontal2 from '@/assets/images/home/pixel-horizontal-2.svg';
|
||||
import pixelHorizontal3 from '@/assets/images/home/pixel-horizontal-3.svg';
|
||||
import facebookSquareIcon from '@/assets/svg/facebook-square.svg';
|
||||
import googleIcon from '@/assets/svg/google.svg';
|
||||
import cnet from '@/assets/svg/cnet.svg';
|
||||
import fastCompany from '@/assets/svg/fast-company.svg';
|
||||
import discover from '@/assets/images/home/discover.svg';
|
||||
import forbes from '@/assets/images/home/forbes.svg';
|
||||
import kickstarter from '@/assets/images/home/kickstarter.svg';
|
||||
import lifehacker from '@/assets/images/home/lifehacker.svg';
|
||||
import makeuseof from '@/assets/images/home/make-use-of.svg';
|
||||
import thenewyorktimes from '@/assets/images/home/the-new-york-times.svg';
|
||||
import * as Analytics from '@/libs/analytics';
|
||||
|
||||
export default {
|
||||
data () {
|
||||
return {
|
||||
icons: Object.freeze({
|
||||
googlePlay,
|
||||
iosAppStore,
|
||||
iphones,
|
||||
spacer,
|
||||
pixelHorizontal,
|
||||
pixelHorizontal2,
|
||||
pixelHorizontal3,
|
||||
facebookIcon: facebookSquareIcon,
|
||||
googleIcon,
|
||||
cnet,
|
||||
fastCompany,
|
||||
discover,
|
||||
forbes,
|
||||
kickstarter,
|
||||
lifehacker,
|
||||
makeuseof,
|
||||
thenewyorktimes,
|
||||
}),
|
||||
userCountInMillions: 3,
|
||||
username: '',
|
||||
password: '',
|
||||
passwordConfirm: '',
|
||||
email: '',
|
||||
usernameIssues: [],
|
||||
};
|
||||
export default {
|
||||
data () {
|
||||
return {
|
||||
icons: Object.freeze({
|
||||
googlePlay,
|
||||
iosAppStore,
|
||||
iphones,
|
||||
spacer,
|
||||
pixelHorizontal,
|
||||
pixelHorizontal2,
|
||||
pixelHorizontal3,
|
||||
facebookIcon: facebookSquareIcon,
|
||||
googleIcon,
|
||||
cnet,
|
||||
fastCompany,
|
||||
discover,
|
||||
forbes,
|
||||
kickstarter,
|
||||
lifehacker,
|
||||
makeuseof,
|
||||
thenewyorktimes,
|
||||
}),
|
||||
userCountInMillions: 3,
|
||||
username: '',
|
||||
password: '',
|
||||
passwordConfirm: '',
|
||||
email: '',
|
||||
usernameIssues: [],
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
emailValid () {
|
||||
if (this.email.length <= 3) return false;
|
||||
return isEmail(this.email);
|
||||
},
|
||||
mounted () {
|
||||
Analytics.track({
|
||||
hitType: 'pageview',
|
||||
eventCategory: 'page',
|
||||
eventAction: 'landing page',
|
||||
page: '/static/home',
|
||||
});
|
||||
emailInvalid () {
|
||||
if (this.email.length <= 3) return false;
|
||||
return !isEmail(this.email);
|
||||
},
|
||||
usernameValid () {
|
||||
if (this.username.length < 1) return false;
|
||||
return this.usernameIssues.length === 0;
|
||||
},
|
||||
usernameInvalid () {
|
||||
if (this.username.length < 1) return false;
|
||||
return !this.usernameValid;
|
||||
},
|
||||
passwordConfirmValid () {
|
||||
if (this.passwordConfirm.length <= 3) return false;
|
||||
return this.passwordConfirm === this.password;
|
||||
},
|
||||
passwordConfirmInvalid () {
|
||||
if (this.passwordConfirm.length <= 3) return false;
|
||||
return this.passwordConfirm !== this.password;
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
username () {
|
||||
this.validateUsername(this.username);
|
||||
},
|
||||
},
|
||||
mounted () {
|
||||
Analytics.track({
|
||||
hitType: 'pageview',
|
||||
eventCategory: 'page',
|
||||
eventAction: 'landing page',
|
||||
page: '/static/home',
|
||||
});
|
||||
|
||||
hello.init({
|
||||
hello.init({
|
||||
facebook: process.env.FACEBOOK_KEY, // eslint-disable-line
|
||||
// windows: WINDOWS_CLIENT_ID,
|
||||
// windows: WINDOWS_CLIENT_ID,
|
||||
google: process.env.GOOGLE_CLIENT_ID, // eslint-disable-line
|
||||
});
|
||||
},
|
||||
computed: {
|
||||
emailValid () {
|
||||
if (this.email.length <= 3) return false;
|
||||
return isEmail(this.email);
|
||||
},
|
||||
emailInvalid () {
|
||||
if (this.email.length <= 3) return false;
|
||||
return !isEmail(this.email);
|
||||
},
|
||||
usernameValid () {
|
||||
if (this.username.length < 1) return false;
|
||||
return this.usernameIssues.length === 0;
|
||||
},
|
||||
usernameInvalid () {
|
||||
if (this.username.length < 1) return false;
|
||||
return !this.usernameValid;
|
||||
},
|
||||
passwordConfirmValid () {
|
||||
if (this.passwordConfirm.length <= 3) return false;
|
||||
return this.passwordConfirm === this.password;
|
||||
},
|
||||
passwordConfirmInvalid () {
|
||||
if (this.passwordConfirm.length <= 3) return false;
|
||||
return this.passwordConfirm !== this.password;
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
username () {
|
||||
this.validateUsername(this.username);
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
// eslint-disable-next-line func-names
|
||||
validateUsername: debounce(function (username) {
|
||||
if (username.length < 1) {
|
||||
return;
|
||||
}
|
||||
this.$store.dispatch('auth:verifyUsername', {
|
||||
username: this.username,
|
||||
}).then(res => {
|
||||
if (res.issues !== undefined) {
|
||||
this.usernameIssues = res.issues;
|
||||
} else {
|
||||
this.usernameIssues = [];
|
||||
}
|
||||
});
|
||||
}, 500),
|
||||
// @TODO this is totally duplicate from the registerLogin component
|
||||
async register () {
|
||||
let groupInvite = '';
|
||||
if (this.$route.query && this.$route.query.p) {
|
||||
groupInvite = this.$route.query.p;
|
||||
}
|
||||
|
||||
if (this.$route.query && this.$route.query.groupInvite) {
|
||||
groupInvite = this.$route.query.groupInvite;
|
||||
}
|
||||
|
||||
await this.$store.dispatch('auth:register', {
|
||||
username: this.username,
|
||||
email: this.email,
|
||||
password: this.password,
|
||||
passwordConfirm: this.passwordConfirm,
|
||||
groupInvite,
|
||||
});
|
||||
|
||||
let redirectTo;
|
||||
|
||||
if (this.$route.query.redirectTo) {
|
||||
redirectTo = this.$route.query.redirectTo;
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
// eslint-disable-next-line func-names
|
||||
validateUsername: debounce(function (username) {
|
||||
if (username.length < 1) {
|
||||
return;
|
||||
}
|
||||
this.$store.dispatch('auth:verifyUsername', {
|
||||
username: this.username,
|
||||
}).then(res => {
|
||||
if (res.issues !== undefined) {
|
||||
this.usernameIssues = res.issues;
|
||||
} else {
|
||||
redirectTo = '/';
|
||||
this.usernameIssues = [];
|
||||
}
|
||||
});
|
||||
}, 500),
|
||||
// @TODO this is totally duplicate from the registerLogin component
|
||||
async register () {
|
||||
let groupInvite = '';
|
||||
if (this.$route.query && this.$route.query.p) {
|
||||
groupInvite = this.$route.query.p;
|
||||
}
|
||||
|
||||
window.location.href = redirectTo;
|
||||
},
|
||||
playButtonClick () {
|
||||
Analytics.track({
|
||||
hitType: 'event',
|
||||
eventCategory: 'button',
|
||||
eventAction: 'click',
|
||||
eventLabel: 'Play',
|
||||
});
|
||||
this.$router.push('/register');
|
||||
},
|
||||
// @TODO: Abstract hello in to action or lib
|
||||
async socialAuth (network) {
|
||||
try {
|
||||
await hello(network).logout();
|
||||
if (this.$route.query && this.$route.query.groupInvite) {
|
||||
groupInvite = this.$route.query.groupInvite;
|
||||
}
|
||||
|
||||
await this.$store.dispatch('auth:register', {
|
||||
username: this.username,
|
||||
email: this.email,
|
||||
password: this.password,
|
||||
passwordConfirm: this.passwordConfirm,
|
||||
groupInvite,
|
||||
});
|
||||
|
||||
let redirectTo;
|
||||
|
||||
if (this.$route.query.redirectTo) {
|
||||
redirectTo = this.$route.query.redirectTo;
|
||||
} else {
|
||||
redirectTo = '/';
|
||||
}
|
||||
|
||||
window.location.href = redirectTo;
|
||||
},
|
||||
playButtonClick () {
|
||||
Analytics.track({
|
||||
hitType: 'event',
|
||||
eventCategory: 'button',
|
||||
eventAction: 'click',
|
||||
eventLabel: 'Play',
|
||||
});
|
||||
this.$router.push('/register');
|
||||
},
|
||||
// @TODO: Abstract hello in to action or lib
|
||||
async socialAuth (network) {
|
||||
try {
|
||||
await hello(network).logout();
|
||||
} catch (e) {} // eslint-disable-line
|
||||
|
||||
const redirectUrl = `${window.location.protocol}//${window.location.host}`;
|
||||
const auth = await hello(network).login({
|
||||
scope: 'email',
|
||||
// explicitly pass the redirect url or it might redirect to /home
|
||||
redirect_uri: redirectUrl, // eslint-disable-line camelcase
|
||||
});
|
||||
const redirectUrl = `${window.location.protocol}//${window.location.host}`;
|
||||
const auth = await hello(network).login({
|
||||
scope: 'email',
|
||||
// explicitly pass the redirect url or it might redirect to /home
|
||||
redirect_uri: redirectUrl, // eslint-disable-line camelcase
|
||||
});
|
||||
|
||||
await this.$store.dispatch('auth:socialAuth', {
|
||||
auth,
|
||||
});
|
||||
await this.$store.dispatch('auth:socialAuth', {
|
||||
auth,
|
||||
});
|
||||
|
||||
window.location.href = '/';
|
||||
},
|
||||
window.location.href = '/';
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user