Add ability to ban/unban users
[oweals/peertube.git] / client / src / app / +admin / users / shared / user.service.ts
index 1af1e4ef2ce82ba9f07045d907840e69bceb617d..ad7fb1eeeb5f8d19f84172b69227fd6568ae7d4d 100644 (file)
@@ -59,6 +59,18 @@ export class UserService {
                .pipe(catchError(err => this.restExtractor.handleError(err)))
   }
 
+  banUser (user: User, reason?: string) {
+    const body = reason ? { reason } : {}
+
+    return this.authHttp.post(UserService.BASE_USERS_URL + user.id + '/block', body)
+               .pipe(catchError(err => this.restExtractor.handleError(err)))
+  }
+
+  unbanUser (user: User) {
+    return this.authHttp.post(UserService.BASE_USERS_URL + user.id + '/unblock', {})
+               .pipe(catchError(err => this.restExtractor.handleError(err)))
+  }
+
   private formatUser (user: User) {
     let videoQuota
     if (user.videoQuota === -1) {