Skip to content
This repository has been archived by the owner on May 26, 2019. It is now read-only.

Add login #1

Merged
merged 15 commits into from
Mar 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 11 additions & 30 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
}

html {
background: url(https://images.pexels.com/photos/443446/pexels-photo-443446.jpeg?cs=srgb&dl=baume-berge-draussen-443446.jpg&fm=jpg) no-repeat center center fixed;
// background: url(https://images.pexels.com/photos/443446/pexels-photo-443446.jpeg?cs=srgb&dl=baume-berge-draussen-443446.jpg&fm=jpg) no-repeat center center fixed;
background-size: cover;
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/NeoChannelPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<metro-messages ref="messageContainer" @messageSent="sendMessage" />
</div>

<metro-list-view class="user-list" acrylic="acrylic-80">
<metro-list-view class="user-list" acrylic="acrylic-80" :key="currentChannel.internalId + userList.length">
<template slot="list-items" v-if="currentChannel && userList.length && groupList.length">
<div v-for="group in groupList" :key="group.internalId" :data-group-identifier="group.internalId">
<div v-if="group.memberIds.some(_ => currentChannel.memberIds.includes(_) )">
Expand Down
4 changes: 2 additions & 2 deletions src/components/NeoChannelUserListItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</div>
<p class="list-view-item-content">
<span class="text-label">{{user.identity.name}}</span>
<span class="detail-text-label">{{user.internalId}}</span>
<span class="detail-text-label">@{{user.identity.id}}</span>
</p>
</div>
</template>
Expand All @@ -21,7 +21,7 @@ export default {
},
mounted() {
this.user = this.userList.find(_ => _.internalId === this.memberId);
console.log(this.user);
//console.log(this.user);
},
updated() {

Expand Down
4 changes: 2 additions & 2 deletions src/scripts/SocketService.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import Vue from "vue";
import CryptoJS from "crypto-js";
import NodeRSA from "node-rsa";

export const SocketService = new Vue({
data: {
Expand Down Expand Up @@ -46,7 +45,8 @@ export const SocketService = new Vue({

if (packageObj.type === 1) {
this.rsaE = CryptoJS.enc.Hex.stringify(CryptoJS.enc.Base64.parse(packageObj.content.exponent));
this.rsaM = CryptoJS.enc.Hex.stringify(CryptoJS.enc.Base64.parse(packageObj.content.modulus));
this.rsaM = CryptoJS.enc.Hex.stringify(CryptoJS.enc.Base64.parse(packageObj.content.modulus));

console.log(this.rsaE);
console.log(this.rsaM);
return;
Expand Down
55 changes: 50 additions & 5 deletions src/views/Login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@
import { SocketService } from "@/scripts/SocketService";
import PackageType from '@/scripts/PackageType';
import { required } from 'vuelidate/lib/validators';
import CryptoJS from "crypto-js";

export default {
name: 'Login',
Expand Down Expand Up @@ -168,14 +169,51 @@ export default {
this.$router.replace("/");
},
onPackage(packageObj) {
console.debug(Object.keys(PackageType).find(t => PackageType[t] === packageObj.type));
console.debug(packageObj.content);

switch (packageObj.type) {
case PackageType.LoginResponse:
if (packageObj.content.status == 0) {
this.isWorking = false;

this.isWorking = false;

if (packageObj.content.status == 0) {
// Login successful
this.$store.commit("setIdentity", packageObj.content.identity);
this.$router.replace("/");
}
} else if (packageObj.content.status == 1) {
// Unknown user
var unknowUserDialog = new metroUI.ContentDialog("Anmeldefehler", (() => {
return (
<div>
<p>Der angegebene Benutzer existiert nicht.</p>
</div>
);
})(), [{ text: "Ok" }]);

unknowUserDialog.show();
} else if (packageObj.content.status == 2) {
// Incorrect password
var incorrectPasswordDialog = new metroUI.ContentDialog("Anmeldefehler", (() => {
return (
<div>
<p>Das Passwort ist falsch.</p>
</div>
);
})(), [{ text: "Ok" }]);

incorrectPasswordDialog.show();
} else if (packageObj.content.status == 3) {
// Unauthorized
var unauthorizedDialog = new metroUI.ContentDialog("Anmeldefehler", (() => {
return (
<div>
<p>Du bist nicht berechtigt dich anzumelden.</p>
</div>
);
})(), [{ text: "Ok" }]);

unauthorizedDialog.show();
}
break;
default: break;
}
Expand All @@ -186,7 +224,14 @@ export default {
},

login() {
this.isWorking = true;
this.isWorking = true;
SocketService.send({
type: PackageType.MemberLogin,
content: {
user: this.user.username,
password: CryptoJS.enc.Base64.stringify(CryptoJS.SHA512(this.user.password))
}
});
},
connectAsGuest() {
this.isWorking = true;
Expand Down
4 changes: 3 additions & 1 deletion src/views/Root.vue
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ export default {
},
methods: {
onPackage(packageObj) {
console.log(packageObj);
console.debug(Object.keys(PackageType).find(t => PackageType[t] === packageObj.type));
console.debug(packageObj.content);

switch (packageObj.type) {
case PackageType.ChannelListUpdate:
this.$store.commit("setChannelList", packageObj.content);
Expand Down