実現したいこと
GoogleSitesでログインページを作り、ログイン完了後にユーザーIDのパラメータを持ったマイページURLに遷移させたいです。
前提
GoogleSitesで会員ページとログイン機能を実装しようとしています。
現在は以下のところまで実装しています。
・スプレッドシートでユーザー情報(IDとパスワード)管理
・SitesのHTMLフォームで入力したデータをGASで取得
・GASで入力データとスプレッドシートを照らし合わせ、認証させる。
・Sitesにパラメータ付きのURLを渡す。
発生している問題・エラーメッセージ
このまま「location.href = "https://sites.google.com/mysite/mypage?number=00000001" 」でページ遷移をさせようとしたのですが、Googleのセキュリティ的な問題で使えませんでした。
どうしてもこのやり方じゃなきゃいけないわけではないです。(GoogleSitesは必須ですが)
GASでスプレッドシート照らし合わせが終わったのちにパラメータ付きで遷移させたいです。
error
1Refused to frame 'https://sites.google.com/' because an ancestor violates the following Content Security Policy directive: 2 "frame-ancestors https://google-admin.corp.google.com/".
該当のソースコード
Index.html
1<head> 2 <meta charset="UTF-8"> 3 <meta name="viewport" content="width=device-width, initial-scale=1.0"> 4 <title>Google Apps Script Example</title> 5 <script> 6 function updateHello() { 7 number = document.getElementById("number").value; 8 var password = document.getElementById("password").value; 9 google.script.run.withSuccessHandler(updateHelloText).sayHello(number, password); 10 } 11 12 function updateHelloText(text) { 13 if(text === "success"){ 14 console.log("success"); 15 document.getElementById("hello").innerText = "login success"; 16 location.href = "https://sites.google.com/mysite/mypage?number=" + number; 17 }else{ 18 console.log("failed"); 19 document.getElementById("hello").innerText = "login failed"; 20 } 21 } 22 </script> 23</head> 24<body> 25 26<!-- テキストボックス --> 27<div>社員番号</div> 28<input type="text" id="number" placeholder="00200000 8桁"> 29<div>パスワード</div> 30<input type="text" id="password"> 31<!-- ボタンをクリックすると GAS の関数が実行される --> 32<button onclick="updateHello()">ログイン</button> 33 34<!-- テキストを表示するための要素 --> 35<h1 id="hello"></h1> 36</body> 37</html>
login.gs
1function doGet() { 2 return HtmlService.createHtmlOutputFromFile('Index') 3 .setTitle('Google Apps Script Example'); 4} 5 6function sayHello(number, password) { 7 var sheet = SpreadsheetApp.openById('spreadsheet no id').getSheetByName('UserData'); 8 var data = sheet.getDataRange().getValues(); 9 10 for (var i=1; i<data.length; i++){ 11 if(data[i][2]==number && data[i][4]==password){ 12 return "success"; 13 } 14 } 15 16 return "login failed"; 17}
試したこと
「Googleサイト ページ遷移」「"GoogleSites" location href」などで検索しましたが、GoogleSites以外での遷移などしかヒットしませんでした。
回答1件
あなたの回答
tips
プレビュー