mirror of
https://github.com/Bubka/2FAuth.git
synced 2025-06-25 22:41:57 +02:00
Reorganize resources/js folder
This commit is contained in:
parent
0176210caf
commit
060f16732a
32
resources/js/app.js
vendored
32
resources/js/app.js
vendored
@ -1,38 +1,22 @@
|
|||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
import VueRouter from 'vue-router'
|
import VueRouter from 'vue-router'
|
||||||
import VueInternationalization from 'vue-i18n';
|
import axios from './packages/axios'
|
||||||
import Locale from './vue-i18n-locales.generated';
|
import i18n from './packages/i18n'
|
||||||
|
import FontAwesome from './packages/fontawesome'
|
||||||
Vue.use(VueRouter)
|
|
||||||
Vue.use(VueInternationalization);
|
|
||||||
|
|
||||||
import App from './views/App'
|
import App from './views/App'
|
||||||
import Login from './views/Login'
|
|
||||||
import Register from './views/Register'
|
|
||||||
import Accounts from './views/Accounts'
|
import Accounts from './views/Accounts'
|
||||||
import Create from './views/Create'
|
import Create from './views/twofaccounts/Create'
|
||||||
import Edit from './views/Edit'
|
import Edit from './views/twofaccounts/Edit'
|
||||||
|
import Login from './views/auth/Login'
|
||||||
|
import Register from './views/auth/Register'
|
||||||
import PasswordRequest from './views/auth/password/Request'
|
import PasswordRequest from './views/auth/password/Request'
|
||||||
import PasswordReset from './views/auth/password/Reset'
|
import PasswordReset from './views/auth/password/Reset'
|
||||||
import NotFound from './views/Error'
|
import NotFound from './views/Error'
|
||||||
|
|
||||||
import './components'
|
import './components'
|
||||||
|
|
||||||
import { library } from '@fortawesome/fontawesome-svg-core'
|
Vue.use(VueRouter)
|
||||||
import { faPlus, faQrcode, faImage, faTrash, faEdit, faCheck, faLock, faLockOpen, faSearch } from '@fortawesome/free-solid-svg-icons'
|
|
||||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
|
|
||||||
|
|
||||||
library.add(faPlus, faQrcode, faImage, faTrash, faEdit, faCheck, faLock, faLockOpen, faSearch);
|
|
||||||
|
|
||||||
Vue.component('font-awesome-icon', FontAwesomeIcon)
|
|
||||||
|
|
||||||
// const lang = document.documentElement.lang.substr(0, 2);
|
|
||||||
const lang = 'en';
|
|
||||||
|
|
||||||
const i18n = new VueInternationalization({
|
|
||||||
locale: lang,
|
|
||||||
messages: Locale
|
|
||||||
});
|
|
||||||
|
|
||||||
const router = new VueRouter({
|
const router = new VueRouter({
|
||||||
mode: 'history',
|
mode: 'history',
|
||||||
|
13
resources/js/packages/axios.js
vendored
Normal file
13
resources/js/packages/axios.js
vendored
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
|
||||||
|
axios.interceptors.request.use(request => {
|
||||||
|
|
||||||
|
const token = localStorage.getItem('jwt')
|
||||||
|
|
||||||
|
if(token) {
|
||||||
|
request.headers.common['Authorization'] = 'Bearer ' + token
|
||||||
|
}
|
||||||
|
|
||||||
|
request.headers.common['Content-Type'] = 'application/json'
|
||||||
|
|
||||||
|
return request
|
||||||
|
})
|
31
resources/js/packages/fontawesome.js
vendored
Normal file
31
resources/js/packages/fontawesome.js
vendored
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
import Vue from 'vue'
|
||||||
|
|
||||||
|
import { library } from '@fortawesome/fontawesome-svg-core'
|
||||||
|
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
|
||||||
|
|
||||||
|
|
||||||
|
import {
|
||||||
|
faPlus,
|
||||||
|
faQrcode,
|
||||||
|
faImage,
|
||||||
|
faTrash,
|
||||||
|
faEdit,
|
||||||
|
faCheck,
|
||||||
|
faLock,
|
||||||
|
faLockOpen,
|
||||||
|
faSearch
|
||||||
|
} from '@fortawesome/free-solid-svg-icons'
|
||||||
|
|
||||||
|
library.add(
|
||||||
|
faPlus,
|
||||||
|
faQrcode,
|
||||||
|
faImage,
|
||||||
|
faTrash,
|
||||||
|
faEdit,
|
||||||
|
faCheck,
|
||||||
|
faLock,
|
||||||
|
faLockOpen,
|
||||||
|
faSearch
|
||||||
|
);
|
||||||
|
|
||||||
|
Vue.component('font-awesome-icon', FontAwesomeIcon)
|
16
resources/js/packages/i18n.js
vendored
Normal file
16
resources/js/packages/i18n.js
vendored
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
import Vue from 'vue'
|
||||||
|
import VueInternationalization from 'vue-i18n';
|
||||||
|
import Locale from './vue-i18n-locales.generated';
|
||||||
|
|
||||||
|
|
||||||
|
Vue.use(VueInternationalization);
|
||||||
|
|
||||||
|
// const lang = document.documentElement.lang.substr(0, 2);
|
||||||
|
const lang = 'en';
|
||||||
|
|
||||||
|
const i18n = new VueInternationalization({
|
||||||
|
locale: lang,
|
||||||
|
messages: Locale
|
||||||
|
});
|
||||||
|
|
||||||
|
export default i18n
|
@ -18,11 +18,12 @@ export default {
|
|||||||
"already_register": "Already registered?",
|
"already_register": "Already registered?",
|
||||||
"password_do_not_match": "Password do not match",
|
"password_do_not_match": "Password do not match",
|
||||||
"forgot_your_password": "Forgot your password?",
|
"forgot_your_password": "Forgot your password?",
|
||||||
"request_password_reset": "Request a password reset"
|
"request_password_reset": "Request a password reset",
|
||||||
},
|
"reset_password": "Reset password",
|
||||||
"send_password_reset_link": "Send password reset link",
|
"new_password": "New password",
|
||||||
"reset_password": "Reset your password",
|
"change_password": "Change password",
|
||||||
"new_password": "New password"
|
"send_password_reset_link": "Send password reset link"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"commons": {
|
"commons": {
|
||||||
"cancel": "Cancel"
|
"cancel": "Cancel"
|
@ -73,17 +73,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="content has-text-centered">
|
<div class="content has-text-centered">
|
||||||
<span v-if="token">
|
{{ $t('auth.hello', {username: username}) }} <a class="has-text-grey" @click="logout">{{ $t('auth.sign_out') }}</a>
|
||||||
{{ $t('auth.hello', {username: username}) }} <a class="has-text-grey" @click="logout">{{ $t('auth.sign_out') }}</a>
|
|
||||||
</span>
|
|
||||||
<span v-else>
|
|
||||||
<router-link :to="{ name: 'login' }" class="button is-black">
|
|
||||||
{{ $t('auth.sign_in') }}
|
|
||||||
</router-link>
|
|
||||||
<router-link :to="{ name: 'register' }" class="button is-black">
|
|
||||||
{{ $t('auth.register') }}
|
|
||||||
</router-link>
|
|
||||||
</span>
|
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
</div>
|
</div>
|
||||||
@ -91,6 +81,7 @@
|
|||||||
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
// import axios from '../packages/axios'
|
||||||
import Modal from '../components/Modal'
|
import Modal from '../components/Modal'
|
||||||
import TwofaccountShow from '../components/TwofaccountShow'
|
import TwofaccountShow from '../components/TwofaccountShow'
|
||||||
import OneTimePassword from '../components/OneTimePassword'
|
import OneTimePassword from '../components/OneTimePassword'
|
||||||
@ -124,11 +115,8 @@
|
|||||||
props: ['InitialEditMode'],
|
props: ['InitialEditMode'],
|
||||||
|
|
||||||
mounted(){
|
mounted(){
|
||||||
this.token = localStorage.getItem('jwt')
|
|
||||||
this.username = localStorage.getItem('user')
|
|
||||||
|
|
||||||
axios.defaults.headers.common['Content-Type'] = 'application/json'
|
this.username = localStorage.getItem('user')
|
||||||
axios.defaults.headers.common['Authorization'] = 'Bearer ' + this.token
|
|
||||||
|
|
||||||
axios.get('api/twofaccounts').then(response => {
|
axios.get('api/twofaccounts').then(response => {
|
||||||
response.data.forEach((data) => {
|
response.data.forEach((data) => {
|
||||||
@ -166,9 +154,6 @@
|
|||||||
getAccount: function (id) {
|
getAccount: function (id) {
|
||||||
let accountId = id
|
let accountId = id
|
||||||
|
|
||||||
axios.defaults.headers.common['Content-Type'] = 'application/json'
|
|
||||||
axios.defaults.headers.common['Authorization'] = 'Bearer ' + this.token
|
|
||||||
|
|
||||||
axios.get('api/twofaccounts/' + id).then(response => {
|
axios.get('api/twofaccounts/' + id).then(response => {
|
||||||
|
|
||||||
this.twofaccount.id = response.data.id
|
this.twofaccount.id = response.data.id
|
||||||
@ -194,9 +179,6 @@
|
|||||||
deleteAccount: function (id) {
|
deleteAccount: function (id) {
|
||||||
if(confirm(this.$t('twofaccounts.confirm.delete'))) {
|
if(confirm(this.$t('twofaccounts.confirm.delete'))) {
|
||||||
|
|
||||||
axios.defaults.headers.common['Content-Type'] = 'application/json'
|
|
||||||
axios.defaults.headers.common['Authorization'] = 'Bearer ' + this.token
|
|
||||||
|
|
||||||
axios.delete('/api/twofaccounts/' + id)
|
axios.delete('/api/twofaccounts/' + id)
|
||||||
|
|
||||||
this.accounts.splice(this.accounts.findIndex(x => x.id === id), 1);
|
this.accounts.splice(this.accounts.findIndex(x => x.id === id), 1);
|
||||||
|
@ -61,8 +61,6 @@
|
|||||||
password: this.password
|
password: this.password
|
||||||
})
|
})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
localStorage.setItem('user',response.data.message.name)
|
|
||||||
localStorage.setItem('jwt',response.data.message.token)
|
|
||||||
|
|
||||||
if (localStorage.getItem('jwt') != null){
|
if (localStorage.getItem('jwt') != null){
|
||||||
this.$router.go('/');
|
this.$router.go('/');
|
@ -92,9 +92,6 @@
|
|||||||
password_confirmation : this.password_confirmation
|
password_confirmation : this.password_confirmation
|
||||||
})
|
})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
localStorage.setItem('user',response.data.message.name)
|
|
||||||
localStorage.setItem('jwt',response.data.message.token)
|
|
||||||
|
|
||||||
if (localStorage.getItem('jwt') != null){
|
if (localStorage.getItem('jwt') != null){
|
||||||
this.$router.go('/');
|
this.$router.go('/');
|
||||||
}
|
}
|
@ -111,11 +111,6 @@
|
|||||||
this.twofaccount.icon = this.tempIcon
|
this.twofaccount.icon = this.tempIcon
|
||||||
|
|
||||||
// store the account
|
// store the account
|
||||||
let token = localStorage.getItem('jwt')
|
|
||||||
|
|
||||||
axios.defaults.headers.common['Content-Type'] = 'application/json'
|
|
||||||
axios.defaults.headers.common['Authorization'] = 'Bearer ' + token
|
|
||||||
|
|
||||||
axios.post('/api/twofaccounts', this.twofaccount)
|
axios.post('/api/twofaccounts', this.twofaccount)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
this.$router.push({name: 'accounts', params: { InitialEditMode: false }});
|
this.$router.push({name: 'accounts', params: { InitialEditMode: false }});
|
||||||
@ -141,11 +136,6 @@
|
|||||||
|
|
||||||
uploadQrcode(event) {
|
uploadQrcode(event) {
|
||||||
|
|
||||||
let token = localStorage.getItem('jwt')
|
|
||||||
|
|
||||||
axios.defaults.headers.common['Content-Type'] = 'application/json'
|
|
||||||
axios.defaults.headers.common['Authorization'] = 'Bearer ' + token
|
|
||||||
|
|
||||||
let imgdata = new FormData();
|
let imgdata = new FormData();
|
||||||
|
|
||||||
imgdata.append('qrcode', this.$refs.qrcodeInput.files[0]);
|
imgdata.append('qrcode', this.$refs.qrcodeInput.files[0]);
|
||||||
@ -174,11 +164,6 @@
|
|||||||
|
|
||||||
uploadIcon(event) {
|
uploadIcon(event) {
|
||||||
|
|
||||||
let token = localStorage.getItem('jwt')
|
|
||||||
|
|
||||||
axios.defaults.headers.common['Content-Type'] = 'application/json'
|
|
||||||
axios.defaults.headers.common['Authorization'] = 'Bearer ' + token
|
|
||||||
|
|
||||||
// clean possible already uploaded temp icon
|
// clean possible already uploaded temp icon
|
||||||
if( this.tempIcon ) {
|
if( this.tempIcon ) {
|
||||||
this.deleteIcon()
|
this.deleteIcon()
|
||||||
@ -214,11 +199,6 @@
|
|||||||
deleteIcon(event) {
|
deleteIcon(event) {
|
||||||
|
|
||||||
if(this.tempIcon) {
|
if(this.tempIcon) {
|
||||||
let token = localStorage.getItem('jwt')
|
|
||||||
|
|
||||||
axios.defaults.headers.common['Content-Type'] = 'application/json'
|
|
||||||
axios.defaults.headers.common['Authorization'] = 'Bearer ' + token
|
|
||||||
|
|
||||||
axios.delete('/api/icon/delete/' + this.tempIcon).then(response => {
|
axios.delete('/api/icon/delete/' + this.tempIcon).then(response => {
|
||||||
this.tempIcon = ''
|
this.tempIcon = ''
|
||||||
}
|
}
|
@ -73,11 +73,6 @@
|
|||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
getAccount: function () {
|
getAccount: function () {
|
||||||
let token = localStorage.getItem('jwt')
|
|
||||||
|
|
||||||
axios.defaults.headers.common['Content-Type'] = 'application/json'
|
|
||||||
axios.defaults.headers.common['Authorization'] = 'Bearer ' + token
|
|
||||||
|
|
||||||
axios.get('/api/twofaccounts/' + this.$route.params.twofaccountId).then(response => {
|
axios.get('/api/twofaccounts/' + this.$route.params.twofaccountId).then(response => {
|
||||||
this.twofaccount = response.data
|
this.twofaccount = response.data
|
||||||
this.twofaccountExists = true
|
this.twofaccountExists = true
|
||||||
@ -109,11 +104,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// store the account
|
// store the account
|
||||||
let token = localStorage.getItem('jwt')
|
|
||||||
|
|
||||||
axios.defaults.headers.common['Content-Type'] = 'application/json'
|
|
||||||
axios.defaults.headers.common['Authorization'] = 'Bearer ' + token
|
|
||||||
|
|
||||||
axios.put('/api/twofaccounts/' + this.$route.params.twofaccountId, this.twofaccount)
|
axios.put('/api/twofaccounts/' + this.$route.params.twofaccountId, this.twofaccount)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
this.$router.push({name: 'accounts', params: { InitialEditMode: true }});
|
this.$router.push({name: 'accounts', params: { InitialEditMode: true }});
|
||||||
@ -142,11 +132,6 @@
|
|||||||
|
|
||||||
uploadIcon(event) {
|
uploadIcon(event) {
|
||||||
|
|
||||||
let token = localStorage.getItem('jwt')
|
|
||||||
|
|
||||||
axios.defaults.headers.common['Content-Type'] = 'application/json'
|
|
||||||
axios.defaults.headers.common['Authorization'] = 'Bearer ' + token
|
|
||||||
|
|
||||||
// clean possible tempIcon but keep original one
|
// clean possible tempIcon but keep original one
|
||||||
// if( this.tempIcon && this.tempIcon !== this.twofaccount.icon ) {
|
// if( this.tempIcon && this.tempIcon !== this.twofaccount.icon ) {
|
||||||
this.deleteIcon()
|
this.deleteIcon()
|
||||||
@ -181,11 +166,6 @@
|
|||||||
deleteIcon(event) {
|
deleteIcon(event) {
|
||||||
|
|
||||||
if( this.tempIcon && this.tempIcon !== this.twofaccount.icon ) {
|
if( this.tempIcon && this.tempIcon !== this.twofaccount.icon ) {
|
||||||
let token = localStorage.getItem('jwt')
|
|
||||||
|
|
||||||
axios.defaults.headers.common['Content-Type'] = 'application/json'
|
|
||||||
axios.defaults.headers.common['Authorization'] = 'Bearer ' + token
|
|
||||||
|
|
||||||
axios.delete('/api/icon/delete/' + this.tempIcon)
|
axios.delete('/api/icon/delete/' + this.tempIcon)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
this.tempIcon = ''
|
this.tempIcon = ''
|
2
webpack.mix.js
vendored
2
webpack.mix.js
vendored
@ -13,7 +13,7 @@ const mix = require('laravel-mix');
|
|||||||
|
|
||||||
mix.js('resources/js/app.js', 'public/js')
|
mix.js('resources/js/app.js', 'public/js')
|
||||||
.js('resources/js/bootstrap.js', 'public/js')
|
.js('resources/js/bootstrap.js', 'public/js')
|
||||||
.js('resources/js/vue-i18n-locales.generated.js', 'public/js')
|
.js('resources/js/packages/vue-i18n-locales.generated.js', 'public/js')
|
||||||
.sass('resources/sass/app.scss', 'public/css');
|
.sass('resources/sass/app.scss', 'public/css');
|
||||||
|
|
||||||
if (mix.inProduction()) {
|
if (mix.inProduction()) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user