-
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.
Merge pull request #76 from katmastt/main
Tokens implementation
- Loading branch information
Showing
19 changed files
with
1,300 additions
and
15 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
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,46 @@ | ||
<?php | ||
|
||
namespace app\models; | ||
|
||
use Yii; | ||
use yii\base\Model; | ||
|
||
class NewTokenRequestForm extends Model | ||
{ | ||
public $name; | ||
public $expiration_date; | ||
|
||
public function rules() | ||
{ | ||
return [ | ||
[['name', 'expiration_date'], 'safe'], | ||
['expiration_date', 'validateDates'], | ||
]; | ||
} | ||
|
||
public function validateDates($date_e, $given_date, $mode) | ||
{ | ||
if (!empty($this->expiration_date)){ | ||
|
||
if (strtotime($this->expiration_date) < strtotime(date("Y-m-d"))) { | ||
if ($mode==0){ | ||
return 'Token creation was unsuccessful: please provide a valid date.'; | ||
} else { | ||
return 'Token edit was unsuccessful: please provide a valid date.'; | ||
} | ||
} elseif ($given_date->format("Y-m-d") > $date_e->format("Y-m-d")) { | ||
if ($mode==0){ | ||
return 'Token creation was unsuccessful: please provide a date that does not exceed the expiration date of the project.'; | ||
} else { | ||
return 'Token edit was unsuccessful: please provide a date that does not exceed the expiration date of the project.'; | ||
} | ||
} else { | ||
return "ok"; | ||
} | ||
} else { | ||
return 'empty'; | ||
} | ||
|
||
} | ||
|
||
} |
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
Oops, something went wrong.