Handle update identity with bad identity username

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2019-11-05 15:03:35 +01:00
parent f91f8ab926
commit 08dab070e7
No known key found for this signature in database
GPG Key ID: A061B9DDE0CA0773
2 changed files with 20 additions and 12 deletions

View File

@ -52,7 +52,7 @@ config :mobilizon, MobilizonWeb.Endpoint,
# Do not include metadata nor timestamps in development logs # Do not include metadata nor timestamps in development logs
config :logger, :console, format: "[$level] $message\n", level: :debug config :logger, :console, format: "[$level] $message\n", level: :debug
config :mobilizon, Mobilizon.Service.Geospatial, service: Mobilizon.Service.Geospatial.Nominatim config :mobilizon, Mobilizon.Service.Geospatial, service: Mobilizon.Service.Geospatial.GoogleMaps
# Set a higher stacktrace during development. Avoid configuring such # Set a higher stacktrace during development. Avoid configuring such
# in production as building large stacktraces may be expensive. # in production as building large stacktraces may be expensive.

View File

@ -134,9 +134,14 @@ export default class EditIdentity extends Vue {
this.resetFields(); this.resetFields();
this.identityName = val; this.identityName = val;
const identity = await this.getIdentity();
if (this.identityName) { if (!identity) {
this.identity = await this.getIdentity(); return await this.$router.push({ name: 'CreateIdentity' });
}
if (this.identityName && identity) {
this.identity = identity;
this.avatarFile = await buildFileFromIPicture(this.identity.avatar); this.avatarFile = await buildFileFromIPicture(this.identity.avatar);
} }
@ -280,15 +285,18 @@ export default class EditIdentity extends Vue {
}); });
} }
private async getIdentity() { private async getIdentity(): Promise<Person|null> {
const result = await this.$apollo.query({ try {
query: FETCH_PERSON, const result = await this.$apollo.query({
variables: { query: FETCH_PERSON,
username: this.identityName, variables: {
}, username: this.identityName,
}); },
});
return new Person(result.data.fetchPerson); return new Person(result.data.fetchPerson);
} catch (e) {
return null;
}
} }
private handleError(err: any) { private handleError(err: any) {