Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
rails_dingtalk
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
other
rails_dingtalk
Commits
5ea2dd5b
Commit
5ea2dd5b
authored
Sep 12, 2021
by
mingyuan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dingtalk
parent
b7b09c64
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
11 deletions
+11
-11
saas.rb
app/apis/dingtalk/api/saas.rb
+2
-3
saas_app.rb
app/models/dingtalk/model/app/saas_app.rb
+7
-7
dingtalk_user.rb
app/models/dingtalk/model/dingtalk_user.rb
+2
-1
No files found.
app/apis/dingtalk/api/saas.rb
View file @
5ea2dd5b
...
@@ -22,7 +22,6 @@ module Dingtalk::Api
...
@@ -22,7 +22,6 @@ module Dingtalk::Api
def
with_access_token
(
method
,
path
,
params
=
{},
headers
=
{},
payload
=
{},
tries
=
2
)
def
with_access_token
(
method
,
path
,
params
=
{},
headers
=
{},
payload
=
{},
tries
=
2
)
app
.
refresh_access_token
unless
app
.
access_token_valid?
app
.
refresh_access_token
unless
app
.
access_token_valid?
payload
.
merge!
(
access_token:
app
.
access_token
)
payload
.
merge!
(
access_token:
app
.
access_token
)
#params.merge!(access_token: app.access_token)
processed_headers
=
sign_header
(
method
,
path
,
params
,
payload
)
processed_headers
=
sign_header
(
method
,
path
,
params
,
payload
)
yield
params
,
processed_headers
yield
params
,
processed_headers
rescue
=>
e
rescue
=>
e
...
@@ -34,8 +33,8 @@ module Dingtalk::Api
...
@@ -34,8 +33,8 @@ module Dingtalk::Api
def
sign_header
(
method
,
path
,
params
=
{},
payload
=
{})
def
sign_header
(
method
,
path
,
params
=
{},
payload
=
{})
headers
=
{
headers
=
{
apiKey:
app
.
app_key
,
apiKey:
app
.
app_key
,
'X-Hmac-Auth-Timestamp'
:
Time
.
now
.
strftime
(
'%Y-%m-%dT%H:%M:%S.%6N%:z'
),
'X-Hmac-Auth-Timestamp'
:
Time
.
now
.
to_s
(
:iso8601
),
'X-Hmac-Auth-Nonce'
:
'16314248251027993'
,
#
(Time.now.to_f * 1000).round.to_s + rand(1000..9999).to_s,
'X-Hmac-Auth-Nonce'
:
(
Time
.
now
.
to_f
*
1000
).
round
.
to_s
+
rand
(
1000
..
9999
).
to_s
,
'X-Hmac-Auth-Version'
:
'1.0'
,
'X-Hmac-Auth-Version'
:
'1.0'
,
'X-Hmac-Auth-IP'
:
RailsDingtalk
.
config
.
ip
,
'X-Hmac-Auth-IP'
:
RailsDingtalk
.
config
.
ip
,
'X-Hmac-Auth-MAC'
:
RailsDingtalk
.
config
.
mac
'X-Hmac-Auth-MAC'
:
RailsDingtalk
.
config
.
mac
...
...
app/models/dingtalk/model/app/saas_app.rb
View file @
5ea2dd5b
...
@@ -10,14 +10,14 @@ module Dingtalk
...
@@ -10,14 +10,14 @@ module Dingtalk
@api
=
Api
::
Saas
.
new
(
self
)
@api
=
Api
::
Saas
.
new
(
self
)
end
end
def
xx
(
code
)
result
=
api
.
getuserinfo
(
code
)
new_app
.
api
.
getuserinfo
(
result
[
'unionid'
])
end
def
generate_user
(
code
)
def
generate_user
(
code
)
r
=
api
.
getuserinfo
(
code
)
info
=
api
.
getuserinfo
(
code
)
binding
.
b
return
unless
info
.
is_a?
(
Hash
)
dingtalk_user
=
dingtalk_users
.
find_or_initialize_by
(
uid:
info
[
'openid'
])
dingtalk_user
.
name
=
info
[
'nickNameCn'
]
dingtalk_user
.
identity
=
info
[
'account'
]
dingtalk_user
.
extra
=
info
.
slice
(
'clientId'
,
'lastName'
,
'realmId'
,
'realmName'
,
'tenantUserId'
,
'employeeCode'
,
'accountId'
,
'tenantId'
,
'tenantName'
,
'referId'
,
'namespace'
)
dingtalk_user
end
end
end
end
...
...
app/models/dingtalk/model/dingtalk_user.rb
View file @
5ea2dd5b
...
@@ -15,7 +15,8 @@ module Dingtalk
...
@@ -15,7 +15,8 @@ module Dingtalk
attribute
:extra
,
:json
,
default:
{}
attribute
:extra
,
:json
,
default:
{}
attribute
:identity
,
:string
,
index:
true
attribute
:identity
,
:string
,
index:
true
belongs_to
:new_app
,
foreign_key: :appid
,
primary_key: :app_key
belongs_to
:new_app
,
foreign_key: :appid
,
primary_key: :app_key
,
optional:
true
belongs_to
:saas_app
,
foreign_key: :appid
,
primary_key: :app_key
,
optional:
true
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment