Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
凌波微步_大先生
dashboard
提交
13aafe3f
D
dashboard
项目概览
凌波微步_大先生
/
dashboard
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dashboard
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
13aafe3f
编写于
6月 12, 2020
作者:
S
Shu Muto
提交者:
GitHub
6月 12, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Save login mode into cookie (#5246)
And use it next time if it exists.
上级
fb340bd5
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
31 addition
and
4 deletion
+31
-4
src/app/frontend/index.config.ts
src/app/frontend/index.config.ts
+2
-0
src/app/frontend/login/component.spec.ts
src/app/frontend/login/component.spec.ts
+7
-1
src/app/frontend/login/component.ts
src/app/frontend/login/component.ts
+22
-3
未找到文件。
src/app/frontend/index.config.ts
浏览文件 @
13aafe3f
...
@@ -23,6 +23,7 @@ export interface Config {
...
@@ -23,6 +23,7 @@ export interface Config {
csrfHeaderName
:
string
;
csrfHeaderName
:
string
;
authTokenHeaderName
:
string
;
authTokenHeaderName
:
string
;
defaultNamespace
:
string
;
defaultNamespace
:
string
;
authModeCookieName
:
string
;
}
}
export
const
CONFIG
:
Config
=
{
export
const
CONFIG
:
Config
=
{
...
@@ -31,6 +32,7 @@ export const CONFIG: Config = {
...
@@ -31,6 +32,7 @@ export const CONFIG: Config = {
csrfHeaderName
:
'
X-CSRF-TOKEN
'
,
csrfHeaderName
:
'
X-CSRF-TOKEN
'
,
skipLoginPageCookieName
:
'
skipLoginPage
'
,
skipLoginPageCookieName
:
'
skipLoginPage
'
,
defaultNamespace
:
'
default
'
,
defaultNamespace
:
'
default
'
,
authModeCookieName
:
'
authMode
'
,
};
};
// Override default material tooltip values.
// Override default material tooltip values.
...
...
src/app/frontend/login/component.spec.ts
浏览文件 @
13aafe3f
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
// limitations under the License.
// limitations under the License.
import
{
HttpClientTestingModule
,
HttpTestingController
}
from
'
@angular/common/http/testing
'
;
import
{
HttpClientTestingModule
,
HttpTestingController
}
from
'
@angular/common/http/testing
'
;
import
{
CUSTOM_ELEMENTS_SCHEMA
}
from
'
@angular/core
'
;
import
{
CUSTOM_ELEMENTS_SCHEMA
,
InjectionToken
}
from
'
@angular/core
'
;
import
{
async
,
ComponentFixture
,
TestBed
}
from
'
@angular/core/testing
'
;
import
{
async
,
ComponentFixture
,
TestBed
}
from
'
@angular/core/testing
'
;
import
{
FormsModule
,
ReactiveFormsModule
}
from
'
@angular/forms
'
;
import
{
FormsModule
,
ReactiveFormsModule
}
from
'
@angular/forms
'
;
import
{
MatButtonModule
}
from
'
@angular/material/button
'
;
import
{
MatButtonModule
}
from
'
@angular/material/button
'
;
...
@@ -23,6 +23,7 @@ import {NoopAnimationsModule} from '@angular/platform-browser/animations';
...
@@ -23,6 +23,7 @@ import {NoopAnimationsModule} from '@angular/platform-browser/animations';
import
{
ActivatedRoute
,
Router
}
from
'
@angular/router
'
;
import
{
ActivatedRoute
,
Router
}
from
'
@angular/router
'
;
import
{
RouterTestingModule
}
from
'
@angular/router/testing
'
;
import
{
RouterTestingModule
}
from
'
@angular/router/testing
'
;
import
{
EnabledAuthenticationModes
,
LoginSkippableResponse
,
LoginSpec
}
from
'
@api/backendapi
'
;
import
{
EnabledAuthenticationModes
,
LoginSkippableResponse
,
LoginSpec
}
from
'
@api/backendapi
'
;
import
{
Config
,
CONFIG_DI_TOKEN
}
from
'
../index.config
'
;
import
{
K8SError
,
KdError
}
from
'
common/errors/errors
'
;
import
{
K8SError
,
KdError
}
from
'
common/errors/errors
'
;
import
{
AuthService
}
from
'
common/services/global/authentication
'
;
import
{
AuthService
}
from
'
common/services/global/authentication
'
;
import
{
from
,
Observable
,
of
}
from
'
rxjs
'
;
import
{
from
,
Observable
,
of
}
from
'
rxjs
'
;
...
@@ -39,6 +40,7 @@ const queries = {
...
@@ -39,6 +40,7 @@ const queries = {
};
};
const
username
=
'
kubedude
'
;
const
username
=
'
kubedude
'
;
const
password
=
'
supersecret
'
;
const
password
=
'
supersecret
'
;
const
MOCK_CONFIG_DI_TOKEN
=
new
InjectionToken
<
Config
>
(
'
kd.config
'
);
class
MockAuthService
{
class
MockAuthService
{
login
(
loginSpec
:
LoginSpec
):
Observable
<
K8SError
[]
>
{
login
(
loginSpec
:
LoginSpec
):
Observable
<
K8SError
[]
>
{
...
@@ -124,6 +126,10 @@ describe('LoginComponent', () => {
...
@@ -124,6 +126,10 @@ describe('LoginComponent', () => {
provide
:
PluginsConfigService
,
provide
:
PluginsConfigService
,
useClass
:
MockPluginsConfigService
,
useClass
:
MockPluginsConfigService
,
},
},
{
provide
:
CONFIG_DI_TOKEN
,
useValue
:
MOCK_CONFIG_DI_TOKEN
,
},
],
],
}).
compileComponents
();
}).
compileComponents
();
}));
}));
...
...
src/app/frontend/login/component.ts
浏览文件 @
13aafe3f
...
@@ -13,12 +13,14 @@
...
@@ -13,12 +13,14 @@
// limitations under the License.
// limitations under the License.
import
{
HttpClient
,
HttpErrorResponse
}
from
'
@angular/common/http
'
;
import
{
HttpClient
,
HttpErrorResponse
}
from
'
@angular/common/http
'
;
import
{
Component
,
NgZone
,
OnInit
}
from
'
@angular/core
'
;
import
{
Component
,
Inject
,
NgZone
,
OnInit
}
from
'
@angular/core
'
;
import
{
ActivatedRoute
,
Router
}
from
'
@angular/router
'
;
import
{
ActivatedRoute
,
Router
}
from
'
@angular/router
'
;
import
{
AuthenticationMode
,
EnabledAuthenticationModes
,
LoginSkippableResponse
,
LoginSpec
}
from
'
@api/backendapi
'
;
import
{
AuthenticationMode
,
EnabledAuthenticationModes
,
LoginSkippableResponse
,
LoginSpec
}
from
'
@api/backendapi
'
;
import
{
KdError
,
KdFile
,
StateError
}
from
'
@api/frontendapi
'
;
import
{
KdError
,
KdFile
,
StateError
}
from
'
@api/frontendapi
'
;
import
{
CookieService
}
from
'
ngx-cookie-service
'
;
import
{
map
}
from
'
rxjs/operators
'
;
import
{
map
}
from
'
rxjs/operators
'
;
import
{
Config
,
CONFIG_DI_TOKEN
}
from
'
../index.config
'
;
import
{
AsKdError
,
K8SError
}
from
'
../common/errors/errors
'
;
import
{
AsKdError
,
K8SError
}
from
'
../common/errors/errors
'
;
import
{
AuthService
}
from
'
../common/services/global/authentication
'
;
import
{
AuthService
}
from
'
../common/services/global/authentication
'
;
import
{
PluginsConfigService
}
from
'
../common/services/global/plugin
'
;
import
{
PluginsConfigService
}
from
'
../common/services/global/plugin
'
;
...
@@ -36,7 +38,7 @@ enum LoginModes {
...
@@ -36,7 +38,7 @@ enum LoginModes {
})
})
export
class
LoginComponent
implements
OnInit
{
export
class
LoginComponent
implements
OnInit
{
loginModes
=
LoginModes
;
loginModes
=
LoginModes
;
selectedAuthenticationMode
=
LoginModes
.
Kubeconfig
;
selectedAuthenticationMode
=
''
;
errors
:
KdError
[]
=
[];
errors
:
KdError
[]
=
[];
private
enabledAuthenticationModes_
:
AuthenticationMode
[]
=
[];
private
enabledAuthenticationModes_
:
AuthenticationMode
[]
=
[];
...
@@ -48,20 +50,27 @@ export class LoginComponent implements OnInit {
...
@@ -48,20 +50,27 @@ export class LoginComponent implements OnInit {
constructor
(
constructor
(
private
readonly
authService_
:
AuthService
,
private
readonly
authService_
:
AuthService
,
private
readonly
cookies_
:
CookieService
,
private
readonly
state_
:
Router
,
private
readonly
state_
:
Router
,
private
readonly
http_
:
HttpClient
,
private
readonly
http_
:
HttpClient
,
private
readonly
ngZone_
:
NgZone
,
private
readonly
ngZone_
:
NgZone
,
private
readonly
route_
:
ActivatedRoute
,
private
readonly
route_
:
ActivatedRoute
,
private
readonly
pluginConfigService_
:
PluginsConfigService
,
private
readonly
pluginConfigService_
:
PluginsConfigService
,
@
Inject
(
CONFIG_DI_TOKEN
)
private
readonly
CONFIG
:
Config
,
)
{}
)
{}
ngOnInit
():
void
{
ngOnInit
():
void
{
this
.
selectedAuthenticationMode
=
this
.
selectedAuthenticationMode
||
this
.
cookies_
.
get
(
this
.
CONFIG
.
authModeCookieName
)
||
''
;
this
.
http_
this
.
http_
.
get
<
EnabledAuthenticationModes
>
(
'
api/v1/login/modes
'
)
.
get
<
EnabledAuthenticationModes
>
(
'
api/v1/login/modes
'
)
.
subscribe
((
enabledModes
:
EnabledAuthenticationModes
)
=>
{
.
subscribe
((
enabledModes
:
EnabledAuthenticationModes
)
=>
{
this
.
enabledAuthenticationModes_
=
enabledModes
.
modes
;
this
.
enabledAuthenticationModes_
=
enabledModes
.
modes
;
this
.
enabledAuthenticationModes_
.
push
(
LoginModes
.
Kubeconfig
);
this
.
enabledAuthenticationModes_
.
push
(
LoginModes
.
Kubeconfig
);
this
.
selectedAuthenticationMode
=
this
.
enabledAuthenticationModes_
[
0
]
as
LoginModes
;
this
.
selectedAuthenticationMode
=
this
.
selectedAuthenticationMode
?
(
this
.
selectedAuthenticationMode
as
LoginModes
)
:
(
this
.
enabledAuthenticationModes_
[
0
]
as
LoginModes
);
});
});
this
.
http_
this
.
http_
...
@@ -82,6 +91,16 @@ export class LoginComponent implements OnInit {
...
@@ -82,6 +91,16 @@ export class LoginComponent implements OnInit {
}
}
login
():
void
{
login
():
void
{
this
.
cookies_
.
set
(
this
.
CONFIG
.
authModeCookieName
,
this
.
selectedAuthenticationMode
,
null
,
null
,
null
,
false
,
'
Strict
'
,
);
this
.
authService_
.
login
(
this
.
getLoginSpec_
()).
subscribe
(
this
.
authService_
.
login
(
this
.
getLoginSpec_
()).
subscribe
(
(
errors
:
K8SError
[])
=>
{
(
errors
:
K8SError
[])
=>
{
if
(
errors
.
length
>
0
)
{
if
(
errors
.
length
>
0
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录