@@ -45,6 +45,8 @@ class User implements JsonSerializable {
45
45
const OPTION_ACL_USER_MODIFY = 0x00200000 ;
46
46
const OPTION_ACL_USER_DELETE = 0x00400000 ;
47
47
48
+ const VERIFICATION_TOKEN_TTL = 86400 ;
49
+
48
50
protected $ created_datetime ;
49
51
protected $ display_name ;
50
52
protected $ email ;
@@ -499,6 +501,23 @@ public function getUsername() {
499
501
return $ this ->username ;
500
502
}
501
503
504
+ public function getVerificationToken () {
505
+ $ key = 'bnetdocs-userverify- ' . $ this ->id ;
506
+ $ value = Common::$ cache ->get ($ key );
507
+
508
+ if ($ value === false ) {
509
+ $ gmp = gmp_init (microtime (true )*10000 );
510
+ $ gmp = gmp_mul ($ gmp , mt_rand ());
511
+ $ gmp = gmp_mul ($ gmp , gmp_random_bits (64 ));
512
+
513
+ $ value = hash ('sha256 ' , gmp_strval ($ gmp , 36 ));
514
+
515
+ Common::$ cache ->set ($ key , $ value , self ::VERIFICATION_TOKEN_TTL );
516
+ }
517
+
518
+ return $ value ;
519
+ }
520
+
502
521
public function getVerifiedDateTime () {
503
522
if (is_null ($ this ->verified_datetime )) {
504
523
return $ this ->verified_datetime ;
@@ -510,6 +529,11 @@ public function getVerifiedDateTime() {
510
529
}
511
530
}
512
531
532
+ public function invalidateVerificationToken () {
533
+ $ key = 'bnetdocs-userverify- ' . $ this ->id ;
534
+ return Common::$ cache ->delete ($ key );
535
+ }
536
+
513
537
public function isStaff () {
514
538
return ($ this ->options_bitmask & (
515
539
self ::OPTION_ACL_DOCUMENT_CREATE |
0 commit comments