-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* generate random test token * format token display * fix prettier lint warning * refactor token formatting using mixin
- Loading branch information
1 parent
12eb77b
commit 74681ba
Showing
4 changed files
with
56 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace App\Helpers; | ||
|
||
class TokenGenerator { | ||
/** | ||
* Generate a random 12-digit token. | ||
* | ||
* @return string | ||
*/ | ||
public static function generate() { | ||
$token = ''; | ||
for ($i = 0; $i < 12; ++$i) { | ||
$token .= random_int(0, 9); | ||
} | ||
|
||
return $token; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export const token = { | ||
methods: { | ||
formatToken(token) { | ||
// Ensure token is a string | ||
const tokenStr = String(token) | ||
// Format in the desired pattern | ||
// return tokenStr.match(/.{1,4}/g).join('-'); // For "1234-1234-1234" | ||
return tokenStr.match(/.{1,3}/g).join(" ") // For "123 412 341 234" | ||
}, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters