#2359 など
This commit is contained in:
		
							parent
							
								
									f0d818de24
								
							
						
					
					
						commit
						30444e5f1a
					
				
					 3 changed files with 6 additions and 1 deletions
				
			
		| 
						 | 
					@ -118,6 +118,7 @@ export interface IRemoteUser extends IUserBase {
 | 
				
			||||||
		publicKeyPem: string;
 | 
							publicKeyPem: string;
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
	updatedAt: Date;
 | 
						updatedAt: Date;
 | 
				
			||||||
 | 
						isAdmin: false;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export type IUser = ILocalUser | IRemoteUser;
 | 
					export type IUser = ILocalUser | IRemoteUser;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -21,7 +21,7 @@ export default (endpoint: string, user: IUser, app: IApp, data: any, file?: any)
 | 
				
			||||||
		return rej('YOUR_ACCOUNT_HAS_BEEN_SUSPENDED');
 | 
							return rej('YOUR_ACCOUNT_HAS_BEEN_SUSPENDED');
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (ep.meta.requireAdmin && !(isLocalUser(user) && user.isAdmin)) {
 | 
						if (ep.meta.requireAdmin && !user.isAdmin) {
 | 
				
			||||||
		return rej('YOU_ARE_NOT_ADMIN');
 | 
							return rej('YOU_ARE_NOT_ADMIN');
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -34,6 +34,10 @@ export default (params: any) => new Promise(async (res, rej) => {
 | 
				
			||||||
		return rej('user not found');
 | 
							return rej('user not found');
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (user.isAdmin) {
 | 
				
			||||||
 | 
							return rej('cannot suspend admin');
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	await User.findOneAndUpdate({
 | 
						await User.findOneAndUpdate({
 | 
				
			||||||
		_id: user._id
 | 
							_id: user._id
 | 
				
			||||||
	}, {
 | 
						}, {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue