Apex を使用したログインプロセスのカスタマイズ
| 必要なユーザ権限 | |
|---|---|
| Visualforce ページを作成し編集する | 「アプリケーションのカスタマイズ」 |
| Apex クラスを編集する | 「Apex 開発」 および 「アプリケーションのカスタマイズ」 |
社外のコミュニティメンバーに、自分の組織のスタイルとブランドを反映した完全なカスタムログインページを提供できます。Visualforce と Apex を使用して、CommunitiesLogin ページと CommunitiesLoginController をカスタマイズするか、独自の Visualforce ページを作成します。
デフォルトのコミュニティログインページからカスタムログインページにリダイレクトする手順は、次のとおりです。
- [設定] から、[クイック検索] ボックスに「Apex クラス」と入力し、[Apex クラス] を選択します。
- CommunitiesLoginController の横にある [編集] をクリックします。
-
次のコードを追加します。
1global PageReference forwardToCustomAuthPage() { 2 String startUrl = System.currentPageReference().getParameters().get('startURL'); 3 return new PageReference(Site.getPathPrefix() + '/SiteLogin?startURL=' + EncodingUtil.urlEncode(startURL, 'UTF-8')); 4 } - 完全なカスタムログインページを作成したら、SiteLogin を Visualforce ページの名前で置き換えます。
- [保存] をクリックします。
- CommunitiesLandingController の横にある [編集] をクリックします。
-
次のコードを追加します。
1public PageReference forwardToCustomAuthPage() { 2 String startUrl = System.currentPageReference().getParameters().get('startURL'); 3 return new PageReference(Site.getPathPrefix() + '/SiteLogin?startURL=' + EncodingUtil.urlEncode(startURL, 'UTF-8')); 4 } - 完全なカスタムログインページを作成したら、SiteLogin を Visualforce ページの名前で置き換えます。
- [保存] をクリックします。
- [設定] から [クイック検索] ボックスに「Visualforce ページ」と入力し、[Visualforce ページ] を選択します。
- CommunitiesLogin の横にある [編集] をクリックします。
-
コードの第 1 行に、次のコードを追加します。
1action="{!forwardToCustomAuthPage}" - [保存] をクリックします。
- CommunitiesLanding の横にある [編集] をクリックします。
-
コードの第 1 行に、次のコードを追加します。
1action="{!forwardToCustomAuthPage}" - [保存] をクリックします。