@@ -27,7 +27,7 @@ class FreeRADIUSUser extends Model {
2727 public StringField $ username ;
2828 public StringField $ password ;
2929 public StringField $ password_encryption ;
30- public BooleanField $ motp_enable ;
30+ public StringField $ motp_enable ;
3131 public StringField $ motp_authmethod ;
3232 public StringField $ motp_secret ;
3333 public StringField $ motp_pin ;
@@ -58,44 +58,42 @@ class FreeRADIUSUser extends Model {
5858
5959 $ this ->password = new StringField (
6060 required: true ,
61- conditions: ['motp_enable ' => false ],
61+ conditions: ['motp_enable ' => ' off ' ],
6262 allow_empty: false ,
6363 allow_null: false ,
6464 internal_name: 'varuserspassword ' ,
6565 sensitive: true ,
6666 );
6767 $ this ->password_encryption = new StringField (
6868 required: false ,
69- conditions: ['motp_enable ' => false ],
69+ conditions: ['motp_enable ' => ' off ' ],
7070 choices: [ 'Cleartext-Password ' , 'MD5-Password ' , 'MD5-Password-hashed ' , 'NT-Password-hashed ' ],
7171 default: 'Cleartext-Password ' ,
7272 internal_name: 'varuserspasswordencryption ' ,
7373 );
7474
75- $ this ->motp_enable = new BooleanField (
76- required: false ,
77- default: false ,
78- indicates_true: 'on ' ,
79- indicates_false: 'off ' ,
75+ $ this ->motp_enable = new StringField (
76+ required: true ,
77+ choices: [ 'on ' , 'off ' ],
8078 internal_name: 'varusersmotpenable ' ,
8179 );
8280 $ this ->motp_authmethod = new StringField (
8381 required: false ,
84- conditions: ['motp_enable ' => true ],
82+ conditions: ['motp_enable ' => ' on ' ],
8583 choices: [ 'motp ' , 'googleauth ' ],
8684 default: 'googleauth ' ,
8785 internal_name: 'varusersauthmethod ' ,
8886 );
8987 $ this ->motp_secret = new StringField (
9088 required: true ,
91- conditions: ['motp_enable ' => true ],
89+ conditions: ['motp_enable ' => ' on ' ],
9290 allow_null: false ,
9391 internal_name: 'varusersmotpinitsecret ' ,
9492 sensitive: true ,
9593 );
9694 $ this ->motp_pin = new StringField (
9795 required: true ,
98- conditions: ['motp_enable ' => true ],
96+ conditions: ['motp_enable ' => ' on ' ],
9997 allow_null: false ,
10098 minimum_length: 4 ,
10199 maximum_length: 4 ,
@@ -104,7 +102,7 @@ class FreeRADIUSUser extends Model {
104102 );
105103 $ this ->motp_offset = new IntegerField (
106104 required: false ,
107- conditions: ['motp_enable ' => true ],
105+ conditions: ['motp_enable ' => ' on ' ],
108106 allow_null: false ,
109107 default: 0 ,
110108 internal_name: 'varusersmotpoffset ' ,
@@ -129,7 +127,12 @@ class FreeRADIUSUser extends Model {
129127 public function _create () {
130128 $ input_errors = [];
131129
130+ if ( $ this ->motp_enable ->value == 'off ' ) {
131+ $ this ->motp_enable ->value = '' ;
132+ }
133+
132134 $ user = $ this ->to_internal ();
135+
133136 freeradius_validate_users ($ user , $ input_errors );
134137
135138 if ( ! empty ($ input_errors ) ) {
0 commit comments