|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Http\Controllers\OAuth; |
|
4
|
|
|
|
|
5
|
|
|
use App\Http\Controllers\Controller; |
|
6
|
|
|
|
|
7
|
|
|
class OAuthController extends Controller |
|
8
|
|
|
{ |
|
9
|
|
|
protected $platformName; |
|
10
|
|
|
protected $platformID; |
|
11
|
|
|
|
|
12
|
|
|
private function generateView($config) { |
|
13
|
|
|
$config+=[ |
|
14
|
|
|
'page_title' => __("oauth.title.platform", ['platform' => $this->platformName]), |
|
15
|
|
|
'site_title' => config("app.name"), |
|
16
|
|
|
'navigation' => "OAuth", |
|
17
|
|
|
'platform' => $this->platformName, |
|
18
|
|
|
]; |
|
19
|
|
|
return view('oauth.index', $config); |
|
20
|
|
|
} |
|
21
|
|
|
|
|
22
|
|
|
protected function generateOperationView($OAuthAccount) { |
|
23
|
|
|
return $this->generateView([ |
|
24
|
|
|
'display_html' => __("oauth.operation", ['platform' => $this->platformName, 'oauthaccount' => $OAuthAccount]), |
|
25
|
|
|
'buttons' => [ |
|
26
|
|
|
[ |
|
27
|
|
|
'text' => __("oauth.action.unbind"), |
|
28
|
|
|
'href' => route("oauth.{$this->platformID}.unbind"), |
|
29
|
|
|
'style' => 'btn-danger' |
|
30
|
|
|
], |
|
31
|
|
|
[ |
|
32
|
|
|
'text' => __("oauth.action.home"), |
|
33
|
|
|
'href' => route('home'), |
|
34
|
|
|
], |
|
35
|
|
|
] |
|
36
|
|
|
]); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
protected function generateDuplicateView($NOJAccount) { |
|
40
|
|
|
return $this->generateView([ |
|
41
|
|
|
'display_html' => __("oauth.duplicate", ['platform' => $this->platformName, 'appname' => config("app.name"), 'nojaccount' => $NOJAccount]), |
|
42
|
|
|
'buttons' => [ |
|
43
|
|
|
[ |
|
44
|
|
|
'text' => __("oauth.action.home"), |
|
45
|
|
|
'href' => route('home'), |
|
46
|
|
|
], |
|
47
|
|
|
] |
|
48
|
|
|
]); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
protected function generateSuccessView($OAuthAccount) { |
|
52
|
|
|
return $this->generateView([ |
|
53
|
|
|
'display_html' => __("oauth.success", ['platform' => $this->platformName, 'appname' => config("app.name"), 'oauthaccount' => $OAuthAccount]), |
|
54
|
|
|
'buttons' => [ |
|
55
|
|
|
[ |
|
56
|
|
|
'text' => __("oauth.action.home"), |
|
57
|
|
|
'href' => route('home'), |
|
58
|
|
|
], |
|
59
|
|
|
] |
|
60
|
|
|
]); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
protected function generateUnknownErrorView() { |
|
64
|
|
|
return $this->generateView([ |
|
65
|
|
|
'display_text' => __("oauth.action.unknownerror"), |
|
66
|
|
|
'buttons' => [ |
|
67
|
|
|
[ |
|
68
|
|
|
'text' => __("oauth.action.retry"), |
|
69
|
|
|
'href' => route('login'), |
|
70
|
|
|
] |
|
71
|
|
|
] |
|
72
|
|
|
]); |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
protected function generateAccountNotFoundView() { |
|
76
|
|
|
$buttons=[[ |
|
77
|
|
|
'text' => __("oauth.action.login"), |
|
78
|
|
|
'href' => route('login'), |
|
79
|
|
|
]]; |
|
80
|
|
|
if (config('function.register')) { |
|
81
|
|
|
$buttons[]=[ |
|
82
|
|
|
'text' => __("oauth.action.register"), |
|
83
|
|
|
'href' => route('register'), |
|
84
|
|
|
]; |
|
85
|
|
|
} |
|
86
|
|
|
return $this->generateView([ |
|
87
|
|
|
'display_text' => __("oauth.accountnotfound", ['platform' => $this->platformName, 'appname' => config("app.name")]), |
|
88
|
|
|
'buttons' => $buttons |
|
89
|
|
|
]); |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
protected function generateUnbindConfirmView($NOJAccount, $OAuthAccount) { |
|
93
|
|
|
return $this->generateView([ |
|
94
|
|
|
'display_html' => __("oauth.unbindconfirm", ['platform' => $this->platformName, 'appname' => config("app.name"), 'oauthaccount' => $OAuthAccount, 'nojaccount' => $NOJAccount]), |
|
95
|
|
|
'buttons' => [ |
|
96
|
|
|
[ |
|
97
|
|
|
'text' => __("oauth.action.confirm"), |
|
98
|
|
|
'href' => route("oauth.{$this->platformID}.unbind.confirm"), |
|
99
|
|
|
'style' => 'btn-danger' |
|
100
|
|
|
], |
|
101
|
|
|
[ |
|
102
|
|
|
'text' => __("oauth.action.home"), |
|
103
|
|
|
'href' => route('home'), |
|
104
|
|
|
], |
|
105
|
|
|
] |
|
106
|
|
|
]); |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
protected function generateAlreadyUnbindView() { |
|
110
|
|
|
return $this->generateView([ |
|
111
|
|
|
'display_html' => __("oauth.alreadyunbind", ['platform' => $this->platformName]), |
|
112
|
|
|
'buttons' => [ |
|
113
|
|
|
[ |
|
114
|
|
|
'text' => __("oauth.action.home"), |
|
115
|
|
|
'href' => route('home'), |
|
116
|
|
|
], |
|
117
|
|
|
] |
|
118
|
|
|
]); |
|
119
|
|
|
} |
|
120
|
|
|
|
|
121
|
|
|
protected function generateUnbindSuccessView() { |
|
122
|
|
|
return $this->generateView([ |
|
123
|
|
|
'display_html' => __("oauth.unbindsuccess", ['platform' => $this->platformName, 'appname' => config("app.name")]), |
|
124
|
|
|
'buttons' => [ |
|
125
|
|
|
[ |
|
126
|
|
|
'text' => __("oauth.action.home"), |
|
127
|
|
|
'href' => route('home'), |
|
128
|
|
|
], |
|
129
|
|
|
] |
|
130
|
|
|
]); |
|
131
|
|
|
} |
|
132
|
|
|
} |
|
133
|
|
|
|