Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
FinClip
ligase
提交
1a026f16
ligase
项目概览
FinClip
/
ligase
通知
33
Star
8
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
ligase
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
1a026f16
编写于
10月 15, 2017
作者:
R
Remi Reuvekamp
提交者:
Erik Johnston
10月 15, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Implement /logout/all (#307)
Signed-off-by:
N
Remi Reuvekamp
<
git@remireuvekamp.nl
>
上级
32a2b3a5
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
59 addition
and
4 deletion
+59
-4
src/github.com/matrix-org/dendrite/clientapi/auth/storage/devices/devices_table.go
.../dendrite/clientapi/auth/storage/devices/devices_table.go
+20
-4
src/github.com/matrix-org/dendrite/clientapi/auth/storage/devices/storage.go
...ix-org/dendrite/clientapi/auth/storage/devices/storage.go
+14
-0
src/github.com/matrix-org/dendrite/clientapi/routing/logout.go
...ithub.com/matrix-org/dendrite/clientapi/routing/logout.go
+19
-0
src/github.com/matrix-org/dendrite/clientapi/routing/routing.go
...thub.com/matrix-org/dendrite/clientapi/routing/routing.go
+6
-0
未找到文件。
src/github.com/matrix-org/dendrite/clientapi/auth/storage/devices/devices_table.go
浏览文件 @
1a026f16
...
...
@@ -57,13 +57,18 @@ const selectDeviceByTokenSQL = "" +
const
deleteDeviceSQL
=
""
+
"DELETE FROM device_devices WHERE device_id = $1 AND localpart = $2"
const
deleteDevicesByLocalpartSQL
=
""
+
"DELETE FROM device_devices WHERE localpart = $1"
// TODO: List devices?
type
devicesStatements
struct
{
insertDeviceStmt
*
sql
.
Stmt
selectDeviceByTokenStmt
*
sql
.
Stmt
deleteDeviceStmt
*
sql
.
Stmt
serverName
gomatrixserverlib
.
ServerName
insertDeviceStmt
*
sql
.
Stmt
selectDeviceByTokenStmt
*
sql
.
Stmt
deleteDeviceStmt
*
sql
.
Stmt
deleteDevicesByLocalpartStmt
*
sql
.
Stmt
serverName
gomatrixserverlib
.
ServerName
}
func
(
s
*
devicesStatements
)
prepare
(
db
*
sql
.
DB
,
server
gomatrixserverlib
.
ServerName
)
(
err
error
)
{
...
...
@@ -80,6 +85,9 @@ func (s *devicesStatements) prepare(db *sql.DB, server gomatrixserverlib.ServerN
if
s
.
deleteDeviceStmt
,
err
=
db
.
Prepare
(
deleteDeviceSQL
);
err
!=
nil
{
return
}
if
s
.
deleteDevicesByLocalpartStmt
,
err
=
db
.
Prepare
(
deleteDevicesByLocalpartSQL
);
err
!=
nil
{
return
}
s
.
serverName
=
server
return
}
...
...
@@ -110,6 +118,14 @@ func (s *devicesStatements) deleteDevice(
return
err
}
func
(
s
*
devicesStatements
)
deleteDevicesByLocalpart
(
ctx
context
.
Context
,
txn
*
sql
.
Tx
,
localpart
string
,
)
error
{
stmt
:=
common
.
TxStmt
(
txn
,
s
.
deleteDevicesByLocalpartStmt
)
_
,
err
:=
stmt
.
ExecContext
(
ctx
,
localpart
)
return
err
}
func
(
s
*
devicesStatements
)
selectDeviceByToken
(
ctx
context
.
Context
,
accessToken
string
,
)
(
*
authtypes
.
Device
,
error
)
{
...
...
src/github.com/matrix-org/dendrite/clientapi/auth/storage/devices/storage.go
浏览文件 @
1a026f16
...
...
@@ -109,3 +109,17 @@ func (d *Database) RemoveDevice(
return
nil
})
}
// RemoveAllDevices revokes devices by deleting the entry in the
// database matching the given user ID localpart.
// If something went wrong during the deletion, it will return the SQL error.
func
(
d
*
Database
)
RemoveAllDevices
(
ctx
context
.
Context
,
localpart
string
,
)
error
{
return
common
.
WithTransaction
(
d
.
db
,
func
(
txn
*
sql
.
Tx
)
error
{
if
err
:=
d
.
devices
.
deleteDevicesByLocalpart
(
ctx
,
txn
,
localpart
);
err
!=
sql
.
ErrNoRows
{
return
err
}
return
nil
})
}
src/github.com/matrix-org/dendrite/clientapi/routing/logout.go
浏览文件 @
1a026f16
...
...
@@ -50,3 +50,22 @@ func Logout(
JSON
:
struct
{}{},
}
}
// LogoutAll handles POST /logout/all
func
LogoutAll
(
req
*
http
.
Request
,
deviceDB
*
devices
.
Database
,
device
*
authtypes
.
Device
,
)
util
.
JSONResponse
{
localpart
,
_
,
err
:=
gomatrixserverlib
.
SplitID
(
'@'
,
device
.
UserID
)
if
err
!=
nil
{
return
httputil
.
LogThenError
(
req
,
err
)
}
if
err
:=
deviceDB
.
RemoveAllDevices
(
req
.
Context
(),
localpart
);
err
!=
nil
{
return
httputil
.
LogThenError
(
req
,
err
)
}
return
util
.
JSONResponse
{
Code
:
200
,
JSON
:
struct
{}{},
}
}
src/github.com/matrix-org/dendrite/clientapi/routing/routing.go
浏览文件 @
1a026f16
...
...
@@ -160,6 +160,12 @@ func Setup(
}),
)
.
Methods
(
"POST"
,
"OPTIONS"
)
r0mux
.
Handle
(
"/logout/all"
,
common
.
MakeAuthAPI
(
"logout"
,
deviceDB
,
func
(
req
*
http
.
Request
,
device
*
authtypes
.
Device
)
util
.
JSONResponse
{
return
LogoutAll
(
req
,
deviceDB
,
device
)
}),
)
.
Methods
(
"POST"
,
"OPTIONS"
)
// Stub endpoints required by Riot
r0mux
.
Handle
(
"/login"
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录