mirror of
https://github.com/itflow-org/itflow
synced 2026-12-02 09:09:01 +00:00
Fix identity provider gaps: a required provider is decided before any password or mail password is checked and the sign-in page says the same whatever was typed, account or not; required beats IMAP on the same domain; after five wrong passwords for an address in ten minutes its mail server isn't asked; Google signs in only Workspace accounts and Nextcloud has to say the address is verified; client secrets are sealed with the install key, with RMM's sealing moved to shared secretSeal and secretOpen; an IMAP server is tried when saved or turned on and Required waits for a first sign-in; joining, Forgot password, password links and welcome emails follow mail-password and required domains; Turn Off says who goes back to a password; 26.12.3 changelog entries
This commit is contained in:
@@ -4,7 +4,8 @@
|
||||
* Joining - from an invite (ours, or a colleague's in the portal) or the link
|
||||
* to finish signing up: ?invite=&token=. The person puts in their name, job
|
||||
* title, phone and a password - or, when an identity provider signs in their address,
|
||||
* chooses that instead - and is made a contact who can sign in
|
||||
* chooses that instead; no password where their mail server checks it (IMAP) or a
|
||||
* provider is required for their domain - and is made a contact who can sign in
|
||||
* (portalInviteAccept(), functions/portal_invite.php). Then they sign in on
|
||||
* the usual page. A link that has run out, been used or cancelled says so,
|
||||
* and what to do instead.
|
||||
@@ -42,6 +43,9 @@ $invite = $link['row'];
|
||||
$error = '';
|
||||
$in = ['name' => '', 'title' => '', 'phone' => ''];
|
||||
|
||||
// Whether a password is chosen here - not where their mail server checks it, or a provider is required for them (functions/identity_provider.php)
|
||||
$password_use = $invite ? identityProviderPasswordUse($invite['invite_email'], 2)['use'] : 'password';
|
||||
|
||||
if ($invite && $link['state'] === 'pending') {
|
||||
// Only an identity provider that signs in their address (functions/identity_provider.php)
|
||||
$methods = portalSignInMethods($invite['invite_email']);
|
||||
@@ -62,9 +66,8 @@ if ($invite && $link['state'] === 'pending') {
|
||||
], $error);
|
||||
if ($contact_id) {
|
||||
$first = strtok(trim(preg_replace('/\s+/', ' ', $in['name'])), ' ');
|
||||
$_SESSION['login_message'] = "Welcome, $first - your account is ready. " . (isset($methods[$method]) && $method === 'azure'
|
||||
? 'Sign in with your ' . identityProviderContactsWording($invite['invite_email']) . ' account below.'
|
||||
: 'Sign in with ' . $invite['invite_email'] . ' and your new password.');
|
||||
$how = portalSignInHow($invite['invite_email'], isset($methods[$method]) ? $method : array_key_first($methods));
|
||||
$_SESSION['login_message'] = "Welcome, $first - your account is ready. " . ($how !== '' ? $how : 'Sign in with ' . $invite['invite_email'] . ' and your new password.');
|
||||
$_SESSION['login_message_type'] = 'success';
|
||||
redirect("/login.php");
|
||||
}
|
||||
@@ -80,7 +83,9 @@ $ask = $by !== '' ? "Ask $by to send it again." : 'Ask your company\'s primary c
|
||||
$notes = [
|
||||
'gone' => ["That link doesn't work", 'It may have been copied only in part - or a newer email replaced it, so use the link in the latest one.'],
|
||||
'expired' => ['That link has run out', $signup ? 'Links to finish signing up work for ' . PORTAL_SIGNUP_LINK_HOURS . ' hours - ask for a new one.' : 'Invites work for ' . PORTAL_INVITE_LINK_DAYS . " days. $ask"],
|
||||
'accepted' => ["You've joined already", 'Sign in with ' . ($invite['invite_email'] ?? 'your email address') . '. Forgot your password? Choose Forgot password on the sign-in page.'],
|
||||
'accepted' => ["You've joined already", $password_use === 'password'
|
||||
? 'Sign in with ' . ($invite['invite_email'] ?? 'your email address') . '. Forgot your password? Choose Forgot password on the sign-in page.'
|
||||
: portalSignInHow($invite['invite_email'], 'local')],
|
||||
'cancelled' => ['That invite was cancelled', $ask],
|
||||
];
|
||||
$state = $link['state'];
|
||||
@@ -158,20 +163,31 @@ $title = $state === 'pending' ? ($signup ? 'Finish signing up' : 'Join ' . $invi
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<label class="form-label small mb-1" for="joinPassword">Choose a password <span class="text-body-secondary">- at least <?= USER_PASSWORD_MIN ?> characters</span></label>
|
||||
<div class="input-group mb-3">
|
||||
<span class="input-group-text"><i class="fas fa-fw fa-lock"></i></span>
|
||||
<input type="password" class="form-control" id="joinPassword" name="new_password" minlength="<?= USER_PASSWORD_MIN ?>" autocomplete="new-password" required<?= $in['name'] !== '' ? ' autofocus' : '' ?>>
|
||||
</div>
|
||||
<div class="input-group mb-3">
|
||||
<span class="input-group-text"><i class="fas fa-fw fa-check-double"></i></span>
|
||||
<input type="password" class="form-control" name="confirm_password" minlength="<?= USER_PASSWORD_MIN ?>" autocomplete="new-password" placeholder="The same again" aria-label="The password again" required>
|
||||
</div>
|
||||
<?php if ($password_use === 'provider') { ?>
|
||||
<!-- A provider is required on their domain - no password here -->
|
||||
<p class="small text-body-secondary mb-3" data-join-password-use="provider"><i class="fas fa-fw fa-id-badge me-1"></i>Accounts on <?= escapeHtml(identityProviderEmailDomain($invite['invite_email'])) ?> sign in with <?= escapeHtml(identityProviderContactsWording($invite['invite_email'])) ?> here, so there is no password to choose.</p>
|
||||
<button type="submit" class="btn btn-primary w-100 mb-3" name="method" value="azure" data-join-microsoft><i class="fas fa-check me-2"></i><?= $signup ? 'Create my account' : 'Join' ?></button>
|
||||
<?php } else { ?>
|
||||
<?php if ($password_use === 'mail') { ?>
|
||||
<!-- Their mail server checks the password typed on the sign-in page -->
|
||||
<p class="small text-body-secondary mb-3" data-join-password-use="mail"><i class="fas fa-fw fa-envelope me-1"></i>You sign in with your email password - the one for your <?= escapeHtml($invite['invite_email']) ?> mailbox - so there is no password to choose here.</p>
|
||||
<?php } else { ?>
|
||||
<label class="form-label small mb-1" for="joinPassword">Choose a password <span class="text-body-secondary">- at least <?= USER_PASSWORD_MIN ?> characters</span></label>
|
||||
<div class="input-group mb-3">
|
||||
<span class="input-group-text"><i class="fas fa-fw fa-lock"></i></span>
|
||||
<input type="password" class="form-control" id="joinPassword" name="new_password" minlength="<?= USER_PASSWORD_MIN ?>" autocomplete="new-password" required<?= $in['name'] !== '' ? ' autofocus' : '' ?>>
|
||||
</div>
|
||||
<div class="input-group mb-3">
|
||||
<span class="input-group-text"><i class="fas fa-fw fa-check-double"></i></span>
|
||||
<input type="password" class="form-control" name="confirm_password" minlength="<?= USER_PASSWORD_MIN ?>" autocomplete="new-password" placeholder="The same again" aria-label="The password again" required>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<button type="submit" class="btn btn-primary w-100 mb-2"><i class="fas fa-check me-2"></i><?= $signup ? 'Create my account' : 'Join' ?></button>
|
||||
<?php if (isset($methods['azure'])) { ?>
|
||||
<div class="text-center small text-body-secondary my-2">or, with no password here</div>
|
||||
<button type="submit" class="btn btn-outline-secondary w-100 mb-3" name="method" value="azure" formnovalidate data-join-microsoft><i class="fas fa-id-badge me-2"></i>Use My <?= escapeHtml(identityProviderContactsWording($invite['invite_email'])) ?> Account</button>
|
||||
<button type="submit" class="btn btn-primary w-100 mb-2"><i class="fas fa-check me-2"></i><?= $signup ? 'Create my account' : 'Join' ?></button>
|
||||
<?php if (isset($methods['azure'])) { ?>
|
||||
<div class="text-center small text-body-secondary my-2">or, with no password here</div>
|
||||
<button type="submit" class="btn btn-outline-secondary w-100 mb-3" name="method" value="azure" formnovalidate data-join-microsoft><i class="fas fa-id-badge me-2"></i>Use My <?= escapeHtml(identityProviderContactsWording($invite['invite_email'])) ?> Account</button>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
</form>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user