Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #1529 管理画面ログイン、ログアウト時の処理を拡張する為のイベントを追加 #1541

Closed
wants to merge 1 commit into from

Conversation

kaburk
Copy link
Collaborator

@kaburk kaburk commented Sep 29, 2020

issues #1529 の件の管理画面ログイン、ログアウト前後のイベントを追加してみました。
よろしくお願いいたします。

@ryuring
Copy link
Collaborator

ryuring commented Oct 2, 2020

@kaburk ありがとうございます。
実装して頂いた、各イベントについて、コールバック処理内で受け取るデータと、本体への影響についての設計を整理したいですね。
そうしないと混乱しそうです。

プルリクの仕様は次となっているようです

  • beforeLogin
    • 受け取るデータ
      • data:送信データ
    • 影響
      • クッキーに保存するデータのみを書換(ログイン対象は別になっている)
  • afterLogin
    • 受け取るデータ
      • data:送信データ
      • user:実際にログインしたユーザ(セッションから)
    • 影響:なし
  • beforeAgentLogin
    • 受け取るデータ
      • data:ユーザID
      • user:ログインユーザー(セッションから)
    • 影響:なし
  • afterAgentLogin
    • 受け取るデータ
      • data:ユーザID
      • user:ログインユーザー(DBから)
    • 影響:なし
  • beforeBackAgent
    • 受け取るデータ
      • data:元のユーザ
      • user:現在のユーザー
    • 影響:なし
  • afterBackAgent
    • 受け取るデータ
      • data:認証プレフィックス
      • user:ログインユーザー(セッションから)
    • 影響:なし
  • beforeLogout
    • 受け取るデータ
      • data:ログインユーザー(セッションから)
    • 影響:処理はあるが影響先はなし
  • afterLogout
    • 受け取るデータ
      • data:ログイアウト後のリダイレクトURL
    • 影響
      • 実際にログアウトするURLを書換

@ryuring
Copy link
Collaborator

ryuring commented Oct 2, 2020

@kaburk 実際の実務などでイベントの実装要件があったのかと思いますが、どういった要求しようでしたか??

@ryuring
Copy link
Collaborator

ryuring commented Oct 2, 2020

イベントの実装として、基本的に、before の処理では、本体に影響を与えることができて、after では影響はない処理にすると仕様がスッキリするかと思います。

@ryuring ryuring self-requested a review October 2, 2020 02:49
@ryuring ryuring self-assigned this Oct 2, 2020
@ryuring ryuring added the Reviewed レビュー済 label Oct 23, 2020
@ryuring ryuring added this to the 4.4.2 milestone Oct 23, 2020
@ryuring
Copy link
Collaborator

ryuring commented Oct 30, 2020

@kaburk こちら次のバージョンで取り込みましょう。


// EVENT Users.beforeLogin
$event = $this->dispatchEvent('beforeLogin', [
'data' => $this->request->data
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

キーを user にしましょう


// EVENT Users.afterLogin
$this->dispatchEvent('afterLogin', [
'data' => $this->request->data,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dataは除外

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

loginRedirect を追加

@@ -170,6 +185,12 @@ public function admin_ajax_agent_login($id) {
$this->Session->write('AuthAgent', $user);
}

// EVENT Users.beforeAgentLogin
$event = $this->dispatchEvent('beforeAgentLogin', [
'data' => $id,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

beforeUserafterUser を引き渡して、代理ログインユーザーを afterUser で書き換える

@@ -179,6 +200,13 @@ public function admin_ajax_agent_login($id) {
if ($user) {
$this->Session->renew();
$this->Session->write(BcAuthComponent::$sessionKey, $user);

// EVENT Users.afterAgentLogin
$this->dispatchEvent('afterAgentLogin', [
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

beforeUserafterUser を引き渡す


// EVENT Users.beforeBackAgent
$event = $this->dispatchEvent('beforeBackAgent', [
'data' => $data,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

beforeUserafterUser を引き渡して、元ログインユーザーを afterUser で書き換える


// EVENT Users.afterBackAgent
$event = $this->dispatchEvent('afterBackAgent', [
'data' => $authPrefix,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dataauthPrefix に変更


// EVENT Users.beforeLogout
$event = $this->dispatchEvent('beforeLogout', [
'data' => $this->BcAuth->user(),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

datauser に変更


// EVENT Users.afterLogout
$event = $this->dispatchEvent('afterLogout', [
'data' => $logoutRedirect,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logoutRedirect に変更

@ryuring
Copy link
Collaborator

ryuring commented Nov 10, 2020

@kaburk レビューが中途半端になってて送信できてなかったので送りました。
こちら調整をお願いします〜

@ryuring ryuring removed this from the 4.4.2 milestone Jan 10, 2021
@gondoh gondoh added this to the 4.4.4 milestone Jan 23, 2021
@gondoh gondoh modified the milestones: 4.4.4, 4.4.5 Feb 25, 2021
@gondoh gondoh modified the milestones: 4.4.5, Adjusting Mar 18, 2021
@kaburk kaburk closed this May 12, 2021
@kaburk kaburk deleted the dev-4-1529 branch May 12, 2021 08:50
@gondoh gondoh modified the milestones: Adjusting, 4.4.7 Jan 20, 2022
@momofff momofff modified the milestones: 4.4.7, close Apr 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Reviewed レビュー済
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants