-
- if ($oid->find()) {
-
- common_element('h2', NULL, _t('OpenID'));
- common_element('p', NULL,
- _t('You can remove an OpenID from your account '.
- 'by clicking the button marked "Delete" next to it.'));
- $idx = 0;
-
- while ($oid->fetch()) {
- common_element_start('form', array('method' => 'POST',
- 'id' => 'openiddelete' . $idx,
- 'action' =>
- common_local_url('openidsettings')));
- common_element_start('p');
- common_element('a', array('href' => $oid->canonical),
- $oid->display);
- common_element('input', array('type' => 'hidden',
- 'id' => 'openid_url'.$idx,
- 'name' => 'openid_url',
- 'value' => $oid->canonical));
- common_element('input', array('type' => 'submit',
- 'id' => 'remove'.$idx,
- 'name' => 'remove',
- 'class' => 'submit',
- 'value' => _t('Remove')));
- common_element_end('p');
- common_element_end('form');
- $idx++;
+
+ $cnt = $oid->find();
+
+ if ($cnt > 0) {
+
+ common_element('h2', NULL, _('Remove OpenID'));
+
+ if ($cnt == 1 && !$user->password) {
+
+ common_element('p', NULL,
+ _('Removing your only OpenID would make it impossible to log in! ' .
+ 'If you need to remove it, add another OpenID first.'));
+
+ if ($oid->fetch()) {
+ common_element_start('p');
+ common_element('a', array('href' => $oid->canonical),
+ $oid->display);
+ common_element_end('p');
+ }
+
+ } else {
+
+ common_element('p', NULL,
+ _('You can remove an OpenID from your account '.
+ 'by clicking the button marked "Remove".'));
+ $idx = 0;
+
+ while ($oid->fetch()) {
+ common_element_start('form', array('method' => 'POST',
+ 'id' => 'openiddelete' . $idx,
+ 'action' =>
+ common_local_url('openidsettings')));
+ common_element_start('p');
+ common_hidden('token', common_session_token());
+ common_element('a', array('href' => $oid->canonical),
+ $oid->display);
+ common_element('input', array('type' => 'hidden',
+ 'id' => 'openid_url'.$idx,
+ 'name' => 'openid_url',
+ 'value' => $oid->canonical));
+ common_element('input', array('type' => 'submit',
+ 'id' => 'remove'.$idx,
+ 'name' => 'remove',
+ 'class' => 'submit',
+ 'value' => _('Remove')));
+ common_element_end('p');
+ common_element_end('form');
+ $idx++;
+ }