YoLo this is Spartaaaaaaaa

This commit is contained in:
Kekskurse 2019-09-25 11:00:55 +02:00
parent 8f3c2754d2
commit 8e871c372d
8 changed files with 229 additions and 7 deletions

View file

@ -64,6 +64,9 @@
</template>
<v-list>
<v-list-item to="/access">
<v-list-item-title>App Access</v-list-item-title>
</v-list-item>
<v-list-item>
<v-list-item-title @click="clickLoogut()">Logout</v-list-item-title>
</v-list-item>

View file

@ -11,6 +11,7 @@ import NewApp from '../views/NewApp'
import Mail from '../views/Mail'
import Invite from '../views/Invite'
import Register from '../views/Register'
import Access from '../views/Access'
Vue.use(Router)
@ -62,6 +63,12 @@ export default new Router({
name: 'Apps',
component: ListApps
},
{
beforeEnter: guard,
path: '/access',
name: 'Access',
component: Access
},
{
beforeEnter: guard,
path: '/apps/new',

View file

@ -30,5 +30,11 @@ export default {
},
newApp(name, description, url) {
return Api().post('/v1/app', {name: name, description: description, url: url});
},
getAccessList() {
return Api().get('/v1/access')
},
removeAccess(accessId) {
return Api().delete('/v1/access/'+accessId)
}
}

View file

@ -4,7 +4,9 @@ export default {
login(username, password, recaptchaToken) {
return Api().post('/v1/user/login', {username: username, password: password, "g-recaptcha-response": recaptchaToken});
},
register(username, password, mail, invite, recaptchaToken) {
return Api().post('/v1/user/register', {username: username, password: password, mail: mail, invite: invite, "g-recaptcha-response": recaptchaToken});
},
setAccessToken(access_token) {
localStorage.setItem('access_token', access_token)
Api().defaults.headers.common['Authorization'] = `Bearer ${access_token}`

134
src/views/Access.vue Normal file
View file

@ -0,0 +1,134 @@
<template>
<div style="margin-top:50px;">
<v-container grid-list-md pa-10 >
<v-layout row wrap>
<v-flex md12>
<h1>App Access</h1>
<br>
<p>The following Apps have Access to your Account, if you revoke the Access the app will get a notifcation about it an may will delete your data.</p>
<v-simple-table>
<template v-slot:default>
<thead>
<tr>
<th></th>
<th class="text-left">Name</th>
<th class="text-left">Created at</th>
<th class="text-left">Info</th>
<th class="text-right" style="max-width: 200px;">Actions</th>
</tr>
</thead>
<tbody>
<tr v-for="item in access" :key="item.name">
<td style="width:30px;">
<img :src="getImageUrl(item.app.id)" style="max-width: 30px;">
</td>
<td>{{ item.app.name }}</td>
<td>{{ item.created }}</td>
<td>
<v-tooltip v-if="item.app.properties.untrustedWarning" bottom>
<template v-slot:activator="{ on }">
<v-icon v-on="on">warning</v-icon>
</template>
<span>App is untrusted!</span>
</v-tooltip>
<v-tooltip v-if="item.app.properties.testingWarning" bottom>
<template v-slot:activator="{ on }">
<v-icon v-on="on">warning</v-icon>
</template>
<span>App is in testing modus!</span>
</v-tooltip>
</td>
<td class="text-right">
<v-btn target="_blank" :href="item.app.url" depressed x-small :disabled="!item.app.url" color="primary" style="margin-right: 10px;">Go to Webpage</v-btn>
<v-btn target="_blank" :href="item.app.directUrl" depressed x-small :disabled="!item.app.directUrl" color="primary" style="margin-right: 10px;">Login to</v-btn>
<v-btn @click="removeAppAccess(item.id)" depressed x-small :disabled="item.app.properties.userCantRemoveApp" color="error">Remove Access</v-btn>
</td>
</tr>
</tbody>
</template>
</v-simple-table>
</v-flex>
</v-layout>
</v-container>
</div>
</template>
<script>
import ServerService from '../services/Server'
import UserService from '../services/User'
import AppService from '../services/Apps'
import LoginComponent from '../components/Login'
export default {
data () {
return {
access: []
}
},
components: {
"Login": LoginComponent
},
methods: {
'getImageUrl' : function (id) {
return AppService.getAppImage(id);
},
removeAppAccess: function(accessId) {
AppService.removeAccess(accessId).then((res) => {
AppService.getAccessList().then((res) => {
this.access = res.data.data
});
});
}
},
mounted: function() {
this.nameBig = this.$store.getters.getSettingValue("name_big");
this.nameSmall = this.$store.getters.getSettingValue("name_small");
AppService.getAccessList().then((res) => {
this.access = res.data.data
});
}
}
</script>
<style>
.bg {
background-image: url('~@/assets/texture-1485529_1920.jpg');
}
.header2 {
background-image: url('~@/assets/texture-1485529_1920.jpg');
background-repeat: no-repeat;
margin-top: -100px;
height: 50vh;
text-align: center;
}
.header h1{
padding-top: 200px;
font-size: 56px !important;
font-weight: 400;
line-height: 32px !important;
letter-spacing: normal !important;
}
.header h1 .small{
font-weight: 300 !important;
}
.header h2{
padding-top: 30px;
font-size: 34px !important;
font-weight: 300;
line-height: 32px !important;
letter-spacing: normal !important;
}
h1{
font-weight: 300;
line-height: 32px !important;
letter-spacing: normal !important;
}
h2{
font-weight: 300;
line-height: 32px !important;
letter-spacing: normal !important;
}
</style>

View file

@ -35,7 +35,12 @@
return AppService.getAppImage(id);
},
'navigateToApp': function(item) {
if(item.directUrl) {
location.href = item.directUrl;
} else {
location.href = item.url;
}
},
'getStartpageApps': function () {
AppService.getStartPageApps().then((res) => {

View file

@ -73,7 +73,6 @@
UserService.getInviteCodeInfo(this.code).then((res) => {
if(res.data.data.usable) {
this.errorMsg = "";
this.$router.push({name: 'Register', query: {code: this.code}});
} else {
this.errorMsg = "Invite code not valide";
}

View file

@ -11,7 +11,13 @@
class="mx-auto"
>
<v-card-title>Register</v-card-title>
<v-card-text>
<v-card-text v-if="success">
Your account is register, you can now login to your Account.<br><br>
<hr><br>
<login-component></login-component>
</v-card-text>
<v-card-text v-if="!success">
<p>Register a new Account</p>
<v-alert type="error" v-if="errorMsg">
@ -23,19 +29,31 @@
value=""
v-model="username"
:disabled=usernameForced
:error-messages=usernameError
:error=usernameErrorFlage
></v-text-field>
<v-text-field
label="Password"
value=""
v-model="password"
type="password"
:error-messages=passwordError
:error=passwordErrorFlag
></v-text-field>
<v-text-field
label="E-Mail"
value=""
v-model="mail"
:error-messages=mailError
:error=mailErrorFlag
></v-text-field>
<div v-if="recaptcha"><vue-recaptcha @verify="onCaptchaVerified" :sitekey="captchaCode"></vue-recaptcha></div>
<v-btn
color="success"
@click="register"
>Register</v-btn>
@ -69,23 +87,68 @@
<script>
import ServerService from '../services/Server'
import UserService from '../services/User'
import VueRecaptcha from 'vue-recaptcha';
import LoginComponent from '../components/Login'
export default {
data () {
return {
success: true,
inviteCode: '',
errorMsg: '',
username: '',
usernameForced: false,
password: '',
mail: ''
mail: '',
recaptcha: false,
captchaCode: '',
recaptchaToken: '',
usernameErrorFlag: false,
usernameError: "",
passwordErrorFlag: false,
passwordError: "",
mailErrorFlag: false,
mailError: ""
}
},
components: {
VueRecaptcha,
LoginComponent
},
methods: {
onCaptchaVerified: function (recaptchaToken) {
this.recaptchaToken = recaptchaToken;
},
register: function () {
UserService.register(this.username, this.password, this.mail, this.$route.query.code, this.recaptchaToken).then((res) => {
this.success = true;
}).catch((error) => {
if(error.response.status == 422){
this.usernameErrorFlag = false;
this.usernameError = "";
this.passwordErrorFlag = false;
this.passwordError = "";
this.mailErrorFlag = false;
this.mailError = "";
if(error.response.data.data.username != undefined) {
this.usernameErrorFlag = true;
this.usernameError = error.response.data.data.username[0]
}
if(error.response.data.data.password != undefined) {
this.passwordErrorFlag = true;
this.passwordError = error.response.data.data.password[0]
}
if(error.response.data.data.mail != undefined) {
this.mailErrorFlag = true;
this.mailError = error.response.data.data.mail[0]
}
console.log(error.response.data.data);
} else {
this.errorMsg = error.response.data.msg;
}
});
}
},
mounted: function() {
this.nameBig = this.$store.getters.getSettingValue("name_big");
@ -104,7 +167,10 @@
this.errorMsg="Invite code not valide";
});
}
console.log(this.$route.query.code)
UserService.getCaptchaSettings().then((res) => {
this.captchaCode = res.data.data.key;
this.recaptcha = res.data.data.register;
});
}
}
</script>