89日目:他人のプロフィールを変更できないようにする
他人のプロフィールを見る事はできても、変更できないようにします。
/var/www/podtv/apps/frontend/modules/profile/action.class.php
public function executeEdit() { if ( ($this->getUser()->isAuthenticated() == false) || ($this->getRequestParameter( 'id') != $this->getUser()->getProfile()->getId()) ) { // 認証済みでなかったら警告を return sfView::ALERT; } $this->sf_guard_user_profile = sfGuardUserProfilePeer::retrieveByPk($this->getRequestParameter('id')); $this->forward404Unless($this->sf_guard_user_profile); }
未認証または他人のプロフィールを編集しようとした場合の警告画面を作ります。
/var/www/podtv/apps/frontend/modules/profile/templates/editAlert.php
<?php use_helper('Object') ?> <h1>アクセス権限がありません</h1> <br /> <?php echo link_to( "login", '/login') .'して下さい<br />'; ?> <br />
http://podtvlabo.com/frontend_dev.php/profile/edit/id/2
というわけで、出来ました。
次はパスワードの変更かな。