2323namespace OCA \Guests ;
2424
2525use OC \Cache \CappedMemoryCache ;
26+ use OCP \EventDispatcher \IEventDispatcher ;
2627use OCP \IDBConnection ;
28+ use OCP \Security \Events \ValidatePasswordPolicyEvent ;
2729use OCP \Security \IHasher ;
2830use OCP \User \Backend \ABackend ;
2931use OCP \User \Backend \ICheckPasswordBackend ;
3234use OCP \User \Backend \IGetHomeBackend ;
3335use OCP \User \Backend \ISetDisplayNameBackend ;
3436use OCP \User \Backend \ISetPasswordBackend ;
35- use Symfony \Component \EventDispatcher \EventDispatcherInterface ;
36- use Symfony \Component \EventDispatcher \GenericEvent ;
3737
3838/**
3939 * Class for user management in a SQL Database (e.g. MySQL, SQLite)
@@ -54,7 +54,7 @@ class UserBackend extends ABackend
5454 private $ allowListing = true ;
5555
5656 public function __construct (
57- EventDispatcherInterface $ eventDispatcher ,
57+ IEventDispatcher $ eventDispatcher ,
5858 IDBConnection $ connection ,
5959 Config $ config ,
6060 IHasher $ hasher
@@ -82,8 +82,7 @@ public function setAllowListing(bool $allow) {
8282 */
8383 public function createUser (string $ uid , string $ password ): bool {
8484 if (!$ this ->userExists ($ uid )) {
85- $ event = new GenericEvent ($ password );
86- $ this ->eventDispatcher ->dispatch ('OCP\PasswordPolicy::validate ' , $ event );
85+ $ this ->eventDispatcher ->dispatchTyped (new ValidatePasswordPolicyEvent ($ password ));
8786
8887 $ qb = $ this ->dbConn ->getQueryBuilder ();
8988 $ qb ->insert ('guests_users ' )
@@ -137,8 +136,7 @@ public function deleteUser($uid) {
137136 */
138137 public function setPassword (string $ uid , string $ password ): bool {
139138 if ($ this ->userExists ($ uid )) {
140- $ event = new GenericEvent ($ password );
141- $ this ->eventDispatcher ->dispatch ('OCP\PasswordPolicy::validate ' , $ event );
139+ $ this ->eventDispatcher ->dispatchTyped (new ValidatePasswordPolicyEvent ($ password ));
142140
143141 $ hashedPassword = $ this ->hasher ->hash ($ password );
144142
0 commit comments