5555 $ app ->auth ->csrf_token_check ();
5656}
5757
58+
59+ // FIXME What's the deal with otp_enabled=v ??
60+
61+
62+
5863//* Handle recovery code
59- if (isset ($ _POST ['code ' ]) && strlen ($ _POST ['code ' ]) == 32 && $ _SESSION ['otp ' ]['recovery ' ])) {
64+ if (isset ($ _POST ['code ' ]) && strlen ($ _POST ['code ' ]) == 32 && $ _SESSION ['otp ' ]['recovery ' ]) {
6065 //* TODO Recovery code handling
6166
6267 $ user = $ app ->db ->queryOneRecord ('SELECT otp_attempts FROM sys_user WHERE userid = ? ' ,$ _SESSION ['s_pending ' ]['user ' ]['userid ' ]);
6671
6772 }
6873
74+ // show reset form to create a new 2fa secret?
6975
7076 die ('Handle recovery code ' );
7177}
104110 die ();
105111 } else {
106112 //* 2fa wrong code
107- $ _SESSION ['otp ' ]['session_attempts ' ]++;
108- $ app ->db ->query ()
113+ $ _SESSION ['otp ' ]['session_attempts ' ]++; // FIXME can't we skip this and rely on the DB only?
114+ $ app ->db ->query (' UPDATE `sys_user` SET otp_attempts=otp_attempts + 1 WHERE userid = ? ' , $ _SESSION [ ' s_pending ' ][ ' user ' ][ ' userid ' ]);
109115 }
110116 }
111117
125131 }
126132
127133 $ app ->uses ('functions ' );
128-
134+ $ app ->uses ('getconf ' );
135+ $ system_config = $ app ->getconf ->get_global_config ();
136+ $ from = $ system_config ['mail ' ]['admin_mail ' ];
137+
138+
129139 //* send email
130140 $ email_to = $ _SESSION ['otp ' ]['data ' ];
131141 $ subject = 'ISPConfig Login authentication ' ;
132- $ text = '' ;
133- $ from = ' root@localhost ' ;
142+ $ text = 'Your One time login code is ' . $ _SESSION [ ' otp ' ][ ' code ' ] . PHP_EOL
143+ . ' This code is valid for 10 minutes ' . PHP_EOL ;
134144
135145 $ app ->functions ->mail ($ email_to , $ subject , $ text , $ from );
136146
144154 }
145155
146156 //* Show form to enter email code
147-
157+ // ... below
148158
149159
150160} else {
153163}
154164
155165
166+ $ logo = $ app ->db ->queryOneRecord ("SELECT * FROM sys_ini WHERE sysini_id = 1 " );
167+ if ($ logo ['custom_logo ' ] != '' ){
168+ $ base64_logo_txt = $ logo ['custom_logo ' ];
169+ } else {
170+ $ base64_logo_txt = $ logo ['default_logo ' ];
171+ }
172+ $ app ->tpl ->setVar ('base64_logo_txt ' , $ base64_logo_txt );
156173
174+ $ app ->tpl ->setVar ('current_theme ' , isset ($ _SESSION ['s ' ]['theme ' ]) ? $ _SESSION ['s ' ]['theme ' ] : 'default ' , true );
157175
158176
159177//* Load templating system and lang file
168186$ app ->tpl ->setVar ('_csrf_key ' ,$ csrf_token ['csrf_key ' ]);
169187
170188
171- $ app ->load_language_file ('web/login/lib/lang/ ' .$ conf ["language " ].'.lng ' );
189+ require ISPC_ROOT_PATH .'/web/login/lib/lang/ ' .$ app ->functions ->check_language ($ conf ['language ' ]).'.lng ' ;
190+ $ app ->tpl ->setVar ($ wb );
172191
173192
174193
178197$ app ->tpl ->pparse ();
179198
180199
181- ?>
200+ ?>
0 commit comments