Show user connection IP and date in admin

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2020-08-31 16:57:13 +02:00
parent 3b1c7e85db
commit a9b8b92ce4
6 changed files with 38 additions and 4 deletions

View File

@ -188,6 +188,10 @@ export const GET_USER = gql`
email
confirmedAt
confirmationSentAt
lastSignInAt
lastSignInIp
currentSignInIp
currentSignInAt
locale
disabled
defaultActor {

View File

@ -791,5 +791,7 @@
"+ Post a public message": "+ Post a public message",
"A cookie is a small file containing information that is sent to your computer when you visit a website. When you visit the site again, the cookie allows that site to recognize your browser. Cookies may store user preferences and other information. You can configure your browser to refuse all cookies. However, this may result in some website features or services partially working. Local storage works the same way but allows you to store more data.": "A cookie is a small file containing information that is sent to your computer when you visit a website. When you visit the site again, the cookie allows that site to recognize your browser. Cookies may store user preferences and other information. You can configure your browser to refuse all cookies. However, this may result in some website features or services partially working. Local storage works the same way but allows you to store more data.",
"A place to publish something to the whole world, your community or just your group members.": "A place to publish something to the whole world, your community or just your group members.",
"No posts found": "No posts found"
"No posts found": "No posts found",
"Last sign-in": "Last sign-in",
"Last IP adress": "Last IP adress"
}

View File

@ -796,5 +796,7 @@
"+ Create an event": "+ Créer un événement",
"+ Post a public message": "+ Poster un message public",
"A place to publish something to the whole world, your community or just your group members.": "Un endroit pour publier quelque chose à l'intention du monde entier, de votre communauté ou simplement des membres de votre groupe.",
"No posts found": "Aucun billet trouvé"
"No posts found": "Aucun billet trouvé",
"Last sign-in": "Dernière connexion",
"Last IP adress": "Dernière addresse IP"
}

View File

@ -26,6 +26,10 @@ export interface IUser extends ICurrentUser {
settings: IUserSettings;
locale: string;
provider?: string;
lastSignInAt: string;
lastSignInIp: string;
currentSignInIp: string;
currentSignInAt: string;
}
export enum IAuthProvider {

View File

@ -59,6 +59,7 @@
</template>
<script lang="ts">
import { Component, Vue, Prop } from "vue-property-decorator";
import { Route } from "vue-router";
import { GET_USER, SUSPEND_USER } from "../../graphql/user";
import { usernameWithDomain } from "../../types/actor/actor.model";
import RouteName from "../../router/name";
@ -90,7 +91,7 @@ export default class AdminUserProfile extends Vue {
RouteName = RouteName;
get metadata(): Array<object> {
get metadata(): Array<Record<string, unknown>> {
if (!this.user) return [];
return [
{
@ -128,6 +129,17 @@ export default class AdminUserProfile extends Vue {
? this.$options.filters.formatDateTimeString(this.user.confirmedAt)
: this.$i18n.t("Not confirmed"),
},
{
key: this.$i18n.t("Last sign-in"),
value:
this.$options.filters && this.user.currentSignInAt
? this.$options.filters.formatDateTimeString(this.user.currentSignInAt)
: this.$t("Unknown"),
},
{
key: this.$i18n.t("Last IP adress"),
value: this.user.currentSignInIp || this.$t("Unknown"),
},
{
key: this.$i18n.t("Participations"),
value: this.user.participations.total,
@ -147,7 +159,7 @@ export default class AdminUserProfile extends Vue {
}
}
async deleteAccount() {
async deleteAccount(): Promise<Route> {
await this.$apollo.mutate<{ suspendProfile: { id: string } }>({
mutation: SUSPEND_USER,
variables: {

View File

@ -83,6 +83,16 @@ defmodule Mobilizon.GraphQL.Schema.UserType do
field(:settings, :user_settings, description: "The list of settings for this user") do
resolve(&User.user_settings/3)
end
field(:last_sign_in_at, :datetime, description: "When the user previously signed-in")
field(:last_sign_in_ip, :string, description: "The IP adress the user previously sign-in with")
field(:current_sign_in_at, :datetime, description: "When the user currenlty signed-in")
field(:current_sign_in_ip, :string,
description: "The IP adress the user's currently signed-in with"
)
end
enum :user_role do