Passed
Push — master ( 9beda0...9f7fca )
by Georg
13:29 queued 11s
created
lib/private/Authentication/Token/RemoteWipe.php 2 patches
Indentation   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -40,75 +40,75 @@
 block discarded – undo
40 40
 
41 41
 class RemoteWipe {
42 42
 
43
-	/** @var IProvider */
44
-	private $tokenProvider;
45
-
46
-	/** @var IEventDispatcher */
47
-	private $eventDispatcher;
48
-
49
-	/** @var ILogger */
50
-	private $logger;
51
-
52
-	public function __construct(IProvider $tokenProvider,
53
-								IEventDispatcher $eventDispatcher,
54
-								ILogger $logger) {
55
-		$this->tokenProvider = $tokenProvider;
56
-		$this->eventDispatcher = $eventDispatcher;
57
-		$this->logger = $logger;
58
-	}
59
-
60
-	/**
61
-	 * @param string $token
62
-	 *
63
-	 * @return bool whether wiping was started
64
-	 * @throws InvalidTokenException
65
-	 *
66
-	 */
67
-	public function start(string $token): bool {
68
-		try {
69
-			$this->tokenProvider->getToken($token);
70
-
71
-			// We expect a WipedTokenException here. If we reach this point this
72
-			// is an ordinary token
73
-			return false;
74
-		} catch (WipeTokenException $e) {
75
-			// Expected -> continue below
76
-		}
77
-
78
-		$dbToken = $e->getToken();
79
-
80
-		$this->logger->info("user " . $dbToken->getUID() . " started a remote wipe");
81
-
82
-		$this->eventDispatcher->dispatch(RemoteWipeStarted::class, new RemoteWipeStarted($dbToken));
83
-
84
-		return true;
85
-	}
86
-
87
-	/**
88
-	 * @param string $token
89
-	 *
90
-	 * @return bool whether wiping could be finished
91
-	 * @throws InvalidTokenException
92
-	 */
93
-	public function finish(string $token): bool {
94
-		try {
95
-			$this->tokenProvider->getToken($token);
96
-
97
-			// We expect a WipedTokenException here. If we reach this point this
98
-			// is an ordinary token
99
-			return false;
100
-		} catch (WipeTokenException $e) {
101
-			// Expected -> continue below
102
-		}
103
-
104
-		$dbToken = $e->getToken();
105
-
106
-		$this->tokenProvider->invalidateToken($token);
107
-
108
-		$this->logger->info("user " . $dbToken->getUID() . " finished a remote wipe");
109
-		$this->eventDispatcher->dispatch(RemoteWipeFinished::class, new RemoteWipeFinished($dbToken));
110
-
111
-		return true;
112
-	}
43
+    /** @var IProvider */
44
+    private $tokenProvider;
45
+
46
+    /** @var IEventDispatcher */
47
+    private $eventDispatcher;
48
+
49
+    /** @var ILogger */
50
+    private $logger;
51
+
52
+    public function __construct(IProvider $tokenProvider,
53
+                                IEventDispatcher $eventDispatcher,
54
+                                ILogger $logger) {
55
+        $this->tokenProvider = $tokenProvider;
56
+        $this->eventDispatcher = $eventDispatcher;
57
+        $this->logger = $logger;
58
+    }
59
+
60
+    /**
61
+     * @param string $token
62
+     *
63
+     * @return bool whether wiping was started
64
+     * @throws InvalidTokenException
65
+     *
66
+     */
67
+    public function start(string $token): bool {
68
+        try {
69
+            $this->tokenProvider->getToken($token);
70
+
71
+            // We expect a WipedTokenException here. If we reach this point this
72
+            // is an ordinary token
73
+            return false;
74
+        } catch (WipeTokenException $e) {
75
+            // Expected -> continue below
76
+        }
77
+
78
+        $dbToken = $e->getToken();
79
+
80
+        $this->logger->info("user " . $dbToken->getUID() . " started a remote wipe");
81
+
82
+        $this->eventDispatcher->dispatch(RemoteWipeStarted::class, new RemoteWipeStarted($dbToken));
83
+
84
+        return true;
85
+    }
86
+
87
+    /**
88
+     * @param string $token
89
+     *
90
+     * @return bool whether wiping could be finished
91
+     * @throws InvalidTokenException
92
+     */
93
+    public function finish(string $token): bool {
94
+        try {
95
+            $this->tokenProvider->getToken($token);
96
+
97
+            // We expect a WipedTokenException here. If we reach this point this
98
+            // is an ordinary token
99
+            return false;
100
+        } catch (WipeTokenException $e) {
101
+            // Expected -> continue below
102
+        }
103
+
104
+        $dbToken = $e->getToken();
105
+
106
+        $this->tokenProvider->invalidateToken($token);
107
+
108
+        $this->logger->info("user " . $dbToken->getUID() . " finished a remote wipe");
109
+        $this->eventDispatcher->dispatch(RemoteWipeFinished::class, new RemoteWipeFinished($dbToken));
110
+
111
+        return true;
112
+    }
113 113
 
114 114
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 
78 78
 		$dbToken = $e->getToken();
79 79
 
80
-		$this->logger->info("user " . $dbToken->getUID() . " started a remote wipe");
80
+		$this->logger->info("user ".$dbToken->getUID()." started a remote wipe");
81 81
 
82 82
 		$this->eventDispatcher->dispatch(RemoteWipeStarted::class, new RemoteWipeStarted($dbToken));
83 83
 
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 
106 106
 		$this->tokenProvider->invalidateToken($token);
107 107
 
108
-		$this->logger->info("user " . $dbToken->getUID() . " finished a remote wipe");
108
+		$this->logger->info("user ".$dbToken->getUID()." finished a remote wipe");
109 109
 		$this->eventDispatcher->dispatch(RemoteWipeFinished::class, new RemoteWipeFinished($dbToken));
110 110
 
111 111
 		return true;
Please login to merge, or discard this patch.
lib/private/Authentication/Listeners/RemoteWipeNotificationsListener.php 1 patch
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -36,36 +36,36 @@
 block discarded – undo
36 36
 
37 37
 class RemoteWipeNotificationsListener implements IEventListener {
38 38
 
39
-	/** @var INotificationManager */
40
-	private $notificationManager;
39
+    /** @var INotificationManager */
40
+    private $notificationManager;
41 41
 
42
-	/** @var ITimeFactory */
43
-	private $timeFactory;
42
+    /** @var ITimeFactory */
43
+    private $timeFactory;
44 44
 
45
-	public function __construct(INotificationManager $notificationManager,
46
-								ITimeFactory $timeFactory) {
47
-		$this->notificationManager = $notificationManager;
48
-		$this->timeFactory = $timeFactory;
49
-	}
45
+    public function __construct(INotificationManager $notificationManager,
46
+                                ITimeFactory $timeFactory) {
47
+        $this->notificationManager = $notificationManager;
48
+        $this->timeFactory = $timeFactory;
49
+    }
50 50
 
51
-	public function handle(Event $event): void {
52
-		if ($event instanceof RemoteWipeStarted) {
53
-			$this->sendNotification('remote_wipe_start', $event->getToken());
54
-		} else if ($event instanceof RemoteWipeFinished) {
55
-			$this->sendNotification('remote_wipe_finish', $event->getToken());
56
-		}
57
-	}
51
+    public function handle(Event $event): void {
52
+        if ($event instanceof RemoteWipeStarted) {
53
+            $this->sendNotification('remote_wipe_start', $event->getToken());
54
+        } else if ($event instanceof RemoteWipeFinished) {
55
+            $this->sendNotification('remote_wipe_finish', $event->getToken());
56
+        }
57
+    }
58 58
 
59
-	private function sendNotification(string $event, IToken $token): void {
60
-		$notification = $this->notificationManager->createNotification();
61
-		$notification->setApp('auth')
62
-			->setUser($token->getUID())
63
-			->setDateTime($this->timeFactory->getDateTime())
64
-			->setObject('token', $token->getId())
65
-			->setSubject($event, [
66
-				'name' => $token->getName(),
67
-			]);
68
-		$this->notificationManager->notify($notification);
69
-	}
59
+    private function sendNotification(string $event, IToken $token): void {
60
+        $notification = $this->notificationManager->createNotification();
61
+        $notification->setApp('auth')
62
+            ->setUser($token->getUID())
63
+            ->setDateTime($this->timeFactory->getDateTime())
64
+            ->setObject('token', $token->getId())
65
+            ->setSubject($event, [
66
+                'name' => $token->getName(),
67
+            ]);
68
+        $this->notificationManager->notify($notification);
69
+    }
70 70
 
71 71
 }
Please login to merge, or discard this patch.
lib/private/Authentication/Listeners/RemoteWipeActivityListener.php 1 patch
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -37,44 +37,44 @@
 block discarded – undo
37 37
 
38 38
 class RemoteWipeActivityListener implements IEventListener {
39 39
 
40
-	/** @var IActvityManager */
41
-	private $activityManager;
40
+    /** @var IActvityManager */
41
+    private $activityManager;
42 42
 
43
-	/** @var ILogger */
44
-	private $logger;
43
+    /** @var ILogger */
44
+    private $logger;
45 45
 
46
-	public function __construct(IActvityManager $activityManager,
47
-								ILogger $logger) {
48
-		$this->activityManager = $activityManager;
49
-		$this->logger = $logger;
50
-	}
46
+    public function __construct(IActvityManager $activityManager,
47
+                                ILogger $logger) {
48
+        $this->activityManager = $activityManager;
49
+        $this->logger = $logger;
50
+    }
51 51
 
52
-	public function handle(Event $event): void {
53
-		if ($event instanceof RemoteWipeStarted) {
54
-			$this->publishActivity('remote_wipe_start', $event->getToken());
55
-		} else if ($event instanceof RemoteWipeFinished) {
56
-			$this->publishActivity('remote_wipe_finish', $event->getToken());
57
-		}
58
-	}
52
+    public function handle(Event $event): void {
53
+        if ($event instanceof RemoteWipeStarted) {
54
+            $this->publishActivity('remote_wipe_start', $event->getToken());
55
+        } else if ($event instanceof RemoteWipeFinished) {
56
+            $this->publishActivity('remote_wipe_finish', $event->getToken());
57
+        }
58
+    }
59 59
 
60
-	private function publishActivity(string $event, IToken $token): void {
61
-		$activity = $this->activityManager->generateEvent();
62
-		$activity->setApp('core')
63
-			->setType('security')
64
-			->setAuthor($token->getUID())
65
-			->setAffectedUser($token->getUID())
66
-			->setSubject($event, [
67
-				'name' => $token->getName(),
68
-			]);
69
-		try {
70
-			$this->activityManager->publish($activity);
71
-		} catch (BadMethodCallException $e) {
72
-			$this->logger->logException($e, [
73
-				'app' => 'core',
74
-				'level' => ILogger::WARN,
75
-				'message' => 'could not publish activity',
76
-			]);
77
-		}
78
-	}
60
+    private function publishActivity(string $event, IToken $token): void {
61
+        $activity = $this->activityManager->generateEvent();
62
+        $activity->setApp('core')
63
+            ->setType('security')
64
+            ->setAuthor($token->getUID())
65
+            ->setAffectedUser($token->getUID())
66
+            ->setSubject($event, [
67
+                'name' => $token->getName(),
68
+            ]);
69
+        try {
70
+            $this->activityManager->publish($activity);
71
+        } catch (BadMethodCallException $e) {
72
+            $this->logger->logException($e, [
73
+                'app' => 'core',
74
+                'level' => ILogger::WARN,
75
+                'message' => 'could not publish activity',
76
+            ]);
77
+        }
78
+    }
79 79
 
80 80
 }
Please login to merge, or discard this patch.
lib/private/Authentication/Events/ARemoteWipeEvent.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -31,16 +31,16 @@
 block discarded – undo
31 31
 
32 32
 abstract class ARemoteWipeEvent extends Event {
33 33
 
34
-	/** @var IToken */
35
-	private $token;
34
+    /** @var IToken */
35
+    private $token;
36 36
 
37
-	public function __construct(IToken $token) {
38
-		parent::__construct();
39
-		$this->token = $token;
40
-	}
37
+    public function __construct(IToken $token) {
38
+        parent::__construct();
39
+        $this->token = $token;
40
+    }
41 41
 
42
-	public function getToken(): IToken {
43
-		return $this->token;
44
-	}
42
+    public function getToken(): IToken {
43
+        return $this->token;
44
+    }
45 45
 
46 46
 }
Please login to merge, or discard this patch.
core/Application.php 1 patch
Indentation   +118 added lines, -118 removed lines patch added patch discarded remove patch
@@ -50,122 +50,122 @@
 block discarded – undo
50 50
  */
51 51
 class Application extends App {
52 52
 
53
-	public function __construct() {
54
-		parent::__construct('core');
55
-
56
-		$container = $this->getContainer();
57
-
58
-		$container->registerService('defaultMailAddress', function () {
59
-			return Util::getDefaultEmailAddress('lostpassword-noreply');
60
-		});
61
-
62
-		$server = $container->getServer();
63
-		/** @var IEventDispatcher $eventDispatcher */
64
-		$eventDispatcher = $server->query(IEventDispatcher::class);
65
-
66
-		$notificationManager = $server->getNotificationManager();
67
-		$notificationManager->registerNotifier(function() use ($server) {
68
-			return new RemoveLinkSharesNotifier(
69
-				$server->getL10NFactory()
70
-			);
71
-		}, function() {
72
-			return [
73
-				'id' => 'core',
74
-				'name' => 'core',
75
-			];
76
-		});
77
-		$notificationManager->registerNotifier(function() use ($server) {
78
-			return $server->query(AuthenticationNotifier::class);
79
-		}, function() {
80
-			return [
81
-				'id' => 'auth',
82
-				'name' => 'authentication notifier',
83
-			];
84
-		});
85
-
86
-		$eventDispatcher->addListener(IDBConnection::CHECK_MISSING_INDEXES_EVENT,
87
-			function(GenericEvent $event) use ($container) {
88
-				/** @var MissingIndexInformation $subject */
89
-				$subject = $event->getSubject();
90
-
91
-				$schema = new SchemaWrapper($container->query(IDBConnection::class));
92
-
93
-				if ($schema->hasTable('share')) {
94
-					$table = $schema->getTable('share');
95
-
96
-					if (!$table->hasIndex('share_with_index')) {
97
-						$subject->addHintForMissingSubject($table->getName(), 'share_with_index');
98
-					}
99
-					if (!$table->hasIndex('parent_index')) {
100
-						$subject->addHintForMissingSubject($table->getName(), 'parent_index');
101
-					}
102
-					if (!$table->hasIndex('owner_index')) {
103
-						$subject->addHintForMissingSubject($table->getName(), 'owner_index');
104
-					}
105
-					if (!$table->hasIndex('initiator_index')) {
106
-						$subject->addHintForMissingSubject($table->getName(), 'initiator_index');
107
-					}
108
-				}
109
-
110
-				if ($schema->hasTable('filecache')) {
111
-					$table = $schema->getTable('filecache');
112
-
113
-					if (!$table->hasIndex('fs_mtime')) {
114
-						$subject->addHintForMissingSubject($table->getName(), 'fs_mtime');
115
-					}
116
-				}
117
-
118
-				if ($schema->hasTable('twofactor_providers')) {
119
-					$table = $schema->getTable('twofactor_providers');
120
-
121
-					if (!$table->hasIndex('twofactor_providers_uid')) {
122
-						$subject->addHintForMissingSubject($table->getName(), 'twofactor_providers_uid');
123
-					}
124
-				}
125
-
126
-				if ($schema->hasTable('login_flow_v2')) {
127
-					$table = $schema->getTable('login_flow_v2');
128
-
129
-					if (!$table->hasIndex('poll_token')) {
130
-						$subject->addHintForMissingSubject($table->getName(), 'poll_token');
131
-					}
132
-					if (!$table->hasIndex('login_token')) {
133
-						$subject->addHintForMissingSubject($table->getName(), 'login_token');
134
-					}
135
-					if (!$table->hasIndex('timestamp')) {
136
-						$subject->addHintForMissingSubject($table->getName(), 'timestamp');
137
-					}
138
-				}
139
-
140
-				if ($schema->hasTable('whats_new')) {
141
-					$table = $schema->getTable('whats_new');
142
-
143
-					if (!$table->hasIndex('version')) {
144
-						$subject->addHintForMissingSubject($table->getName(), 'version');
145
-					}
146
-				}
147
-
148
-				if ($schema->hasTable('cards')) {
149
-					$table = $schema->getTable('cards');
150
-
151
-					if (!$table->hasIndex('cards_abid')) {
152
-						$subject->addHintForMissingSubject($table->getName(), 'cards_abid');
153
-					}
154
-				}
155
-
156
-				if ($schema->hasTable('cards_properties')) {
157
-					$table = $schema->getTable('cards_properties');
158
-
159
-					if (!$table->hasIndex('cards_prop_abid')) {
160
-						$subject->addHintForMissingSubject($table->getName(), 'cards_prop_abid');
161
-					}
162
-				}
163
-			}
164
-		);
165
-
166
-		$eventDispatcher->addServiceListener(RemoteWipeStarted::class, RemoteWipeActivityListener::class);
167
-		$eventDispatcher->addServiceListener(RemoteWipeStarted::class, RemoteWipeNotificationsListener::class);
168
-		$eventDispatcher->addServiceListener(RemoteWipeFinished::class, RemoteWipeActivityListener::class);
169
-		$eventDispatcher->addServiceListener(RemoteWipeFinished::class, RemoteWipeNotificationsListener::class);
170
-	}
53
+    public function __construct() {
54
+        parent::__construct('core');
55
+
56
+        $container = $this->getContainer();
57
+
58
+        $container->registerService('defaultMailAddress', function () {
59
+            return Util::getDefaultEmailAddress('lostpassword-noreply');
60
+        });
61
+
62
+        $server = $container->getServer();
63
+        /** @var IEventDispatcher $eventDispatcher */
64
+        $eventDispatcher = $server->query(IEventDispatcher::class);
65
+
66
+        $notificationManager = $server->getNotificationManager();
67
+        $notificationManager->registerNotifier(function() use ($server) {
68
+            return new RemoveLinkSharesNotifier(
69
+                $server->getL10NFactory()
70
+            );
71
+        }, function() {
72
+            return [
73
+                'id' => 'core',
74
+                'name' => 'core',
75
+            ];
76
+        });
77
+        $notificationManager->registerNotifier(function() use ($server) {
78
+            return $server->query(AuthenticationNotifier::class);
79
+        }, function() {
80
+            return [
81
+                'id' => 'auth',
82
+                'name' => 'authentication notifier',
83
+            ];
84
+        });
85
+
86
+        $eventDispatcher->addListener(IDBConnection::CHECK_MISSING_INDEXES_EVENT,
87
+            function(GenericEvent $event) use ($container) {
88
+                /** @var MissingIndexInformation $subject */
89
+                $subject = $event->getSubject();
90
+
91
+                $schema = new SchemaWrapper($container->query(IDBConnection::class));
92
+
93
+                if ($schema->hasTable('share')) {
94
+                    $table = $schema->getTable('share');
95
+
96
+                    if (!$table->hasIndex('share_with_index')) {
97
+                        $subject->addHintForMissingSubject($table->getName(), 'share_with_index');
98
+                    }
99
+                    if (!$table->hasIndex('parent_index')) {
100
+                        $subject->addHintForMissingSubject($table->getName(), 'parent_index');
101
+                    }
102
+                    if (!$table->hasIndex('owner_index')) {
103
+                        $subject->addHintForMissingSubject($table->getName(), 'owner_index');
104
+                    }
105
+                    if (!$table->hasIndex('initiator_index')) {
106
+                        $subject->addHintForMissingSubject($table->getName(), 'initiator_index');
107
+                    }
108
+                }
109
+
110
+                if ($schema->hasTable('filecache')) {
111
+                    $table = $schema->getTable('filecache');
112
+
113
+                    if (!$table->hasIndex('fs_mtime')) {
114
+                        $subject->addHintForMissingSubject($table->getName(), 'fs_mtime');
115
+                    }
116
+                }
117
+
118
+                if ($schema->hasTable('twofactor_providers')) {
119
+                    $table = $schema->getTable('twofactor_providers');
120
+
121
+                    if (!$table->hasIndex('twofactor_providers_uid')) {
122
+                        $subject->addHintForMissingSubject($table->getName(), 'twofactor_providers_uid');
123
+                    }
124
+                }
125
+
126
+                if ($schema->hasTable('login_flow_v2')) {
127
+                    $table = $schema->getTable('login_flow_v2');
128
+
129
+                    if (!$table->hasIndex('poll_token')) {
130
+                        $subject->addHintForMissingSubject($table->getName(), 'poll_token');
131
+                    }
132
+                    if (!$table->hasIndex('login_token')) {
133
+                        $subject->addHintForMissingSubject($table->getName(), 'login_token');
134
+                    }
135
+                    if (!$table->hasIndex('timestamp')) {
136
+                        $subject->addHintForMissingSubject($table->getName(), 'timestamp');
137
+                    }
138
+                }
139
+
140
+                if ($schema->hasTable('whats_new')) {
141
+                    $table = $schema->getTable('whats_new');
142
+
143
+                    if (!$table->hasIndex('version')) {
144
+                        $subject->addHintForMissingSubject($table->getName(), 'version');
145
+                    }
146
+                }
147
+
148
+                if ($schema->hasTable('cards')) {
149
+                    $table = $schema->getTable('cards');
150
+
151
+                    if (!$table->hasIndex('cards_abid')) {
152
+                        $subject->addHintForMissingSubject($table->getName(), 'cards_abid');
153
+                    }
154
+                }
155
+
156
+                if ($schema->hasTable('cards_properties')) {
157
+                    $table = $schema->getTable('cards_properties');
158
+
159
+                    if (!$table->hasIndex('cards_prop_abid')) {
160
+                        $subject->addHintForMissingSubject($table->getName(), 'cards_prop_abid');
161
+                    }
162
+                }
163
+            }
164
+        );
165
+
166
+        $eventDispatcher->addServiceListener(RemoteWipeStarted::class, RemoteWipeActivityListener::class);
167
+        $eventDispatcher->addServiceListener(RemoteWipeStarted::class, RemoteWipeNotificationsListener::class);
168
+        $eventDispatcher->addServiceListener(RemoteWipeFinished::class, RemoteWipeActivityListener::class);
169
+        $eventDispatcher->addServiceListener(RemoteWipeFinished::class, RemoteWipeNotificationsListener::class);
170
+    }
171 171
 }
Please login to merge, or discard this patch.