@**
 * Copyright (c) 2014, 2018-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/>.
 *@

@(origNonceBack: String, idpName: String, idpHasVerifiedEmail: Boolean,
    newUserUsername: String, newUserFullName: String, newUserEmail: String,
    authDataCacheKey: String, anyContinueToUrl: Option[String],
    winOpenerParamsJsonSt: String = "")

@* Closes the Identity Provider authentication popup window, and opens a
 * create user dialog in the window.opener instead (which should be the
 * main page where e.g. a forum topic and all replies are shown).
 *
 * Not for embedded comments logins, because then we'll continue running inside
 * the popup, see showCreateUserDialogInThisWin.scala.html  — would be tricky,
 * UX wise, to try to show a create-user dialog in Talkyard's iframe.
 *@

@continueToUrlOrEmpty = @{
  anyContinueToUrl getOrElse ""
}

<!DOCTYPE html>
<html>
<body>
<!-- views/authn/showCreateUserDialogInOpenerCloseCurWin.scala.html -->
@* [script_src_self] *@
@* 
<script id="winOpenerParams" type="application/json">
@Html(Encode.forHtmlContent(winOpenerParamsJsonSt))
</script>
<script type='text/javascript' src='call-win-opener-and-close.js'></script>
*@
<script type='text/javascript'>
    window.opener.debiki2.morebundle.showCreateUserDialog({
      origNonceBack: '@origNonceBack',
      idpName: '@idpName',
      idpHasVerifiedEmail: @idpHasVerifiedEmail,
      username: '@newUserUsername',
      fullName: '@newUserFullName',
      email: '@newUserEmail',
      authDataCacheKey: '@authDataCacheKey',
      anyReturnToUrl: '@continueToUrlOrEmpty'
    });
    window.close();
</script>
<p>
  Facebook mobile app problem?
</p>
<p>
  Did you go to here, via Facebook's mobile app?
  If so, you're likely using Facebook's built-in browser. It makes things break.
</p>
<p>
  Instead, copy the login URL, and log in outside Facebook.
  (Or outside any other mobile app you're using, if not Facebook?)
</p>
</body>
</html>

