thelounge/client/components/Session.vue

51 lines
961 B
Vue
Raw Normal View History

2019-03-03 17:47:49 +00:00
<template>
<p>
2019-08-03 19:03:45 +00:00
<button class="btn pull-right remove-session" @click.prevent="signOut">
2019-03-03 17:47:49 +00:00
<template v-if="session.current">
Sign out
</template>
<template v-else>
Revoke
</template>
</button>
<strong>{{ session.agent }}</strong>
2019-08-03 19:03:45 +00:00
<a :href="'https://ipinfo.io/' + session.ip" target="_blank" rel="noopener">{{
session.ip
}}</a>
2019-03-03 17:47:49 +00:00
<template v-if="!session.current">
2019-08-03 19:03:45 +00:00
<br />
2019-03-03 17:47:49 +00:00
<template v-if="session.active">
<em>Currently active</em>
</template>
<template v-else>
Last used on <time>{{ session.lastUse | localetime }}</time>
</template>
</template>
</p>
</template>
<script>
2019-11-16 17:24:03 +00:00
import Auth from "../js/auth";
import socket from "../js/socket";
2019-03-03 17:47:49 +00:00
export default {
name: "Session",
props: {
session: Object,
},
methods: {
signOut() {
if (!this.session.current) {
socket.emit("sign-out", this.session.token);
} else {
socket.emit("sign-out");
Auth.signout();
}
},
},
};
</script>