@**
 * Copyright (c) 2014, 2019 Kaj Magnus Lindberg
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *@

@(tpi: debiki.SiteTpi, serverAddress: String,
    origNonceBack: String, idpName: String, idpHasVerifiedEmail: Boolean,
    newUserUsername: String, newUserFullName: String, newUserEmail: String,
    authDataCacheKey: String, anyContinueToUrl: Option[String])

@* After authentication at an Identity Provider (IDP) in this window,
 * we show a create user dialog, in this same window.
 * This is 1) for embedded comments pages — then, login and user creation always
 * happens in a login popup window (this window), because wouldn't work well
 * to show a create user dialog in Talkyard's iframe on the blog page.
 * And 2) for logging in in the whole main window, to e.g. the admin area, or if the
 * site requires login — then, this happens in the main win itself (no login popup).
 *
 * So don't call window.close() here. But in
 * showCreateUserDialogInOpenerCloseCurWin.scala.html, we do the same things
 * and *also* call window.close(), and continue in the opener instead,
 * by showing the create-user dialog, there.
 *@

@continueToUrlOrEmpty = @{
  anyContinueToUrl getOrElse ""
}

@authnPageHtmlDoc(tpi, serverAddress) {
  <!-- views/authn/showCreateUserDialogInThisWin.scala.html -->
  <script>@* [script_src_self] *@
    debiki2.morebundle.showCreateUserDialog({
      origNonceBack: '@origNonceBack',
      idpName: '@idpName',
      idpHasVerifiedEmail: @idpHasVerifiedEmail,
      username: '@newUserUsername',
      fullName: '@newUserFullName',
      email: '@newUserEmail',
      authDataCacheKey: '@authDataCacheKey',
      anyReturnToUrl: '@continueToUrlOrEmpty',
      preventClose: true
    });
  </script>
}

