fix: check if user exists in show() function
This commit is contained in:
parent
534242907d
commit
6647de2a6f
1 changed files with 11 additions and 15 deletions
|
|
@ -23,28 +23,24 @@ class UserProfile {
|
|||
}
|
||||
|
||||
show() {
|
||||
this.route = frappe.get_route();
|
||||
let route = frappe.get_route();
|
||||
this.user_id = route[1] || frappe.session.user;
|
||||
|
||||
//validate if user
|
||||
if (this.route.length > 1) {
|
||||
let user_id = this.route.slice(-1)[0];
|
||||
this.check_user_exists(user_id);
|
||||
if (route.length > 1) {
|
||||
frappe.db.exists('User', this.user_id).then( exists => {
|
||||
if (exists) {
|
||||
this.make_user_profile();
|
||||
} else {
|
||||
frappe.msgprint(__('User does not exist'));
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.user_id = frappe.session.user;
|
||||
this.make_user_profile();
|
||||
}
|
||||
}
|
||||
|
||||
check_user_exists(user) {
|
||||
frappe.db.exists('User', user).then( exists => {
|
||||
if (!exists) {
|
||||
frappe.msgprint(__('User does not exist'));
|
||||
} else {
|
||||
this.user_id = user;
|
||||
this.make_user_profile();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
make_user_profile() {
|
||||
frappe.set_route('user-profile', this.user_id);
|
||||
this.user = frappe.user_info(this.user_id);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue