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
0ebdd496
Commit
0ebdd496
authored
Sep 11, 2021
by
mingyuan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dingtalk
parent
b24bb8a7
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
25 additions
and
6 deletions
+25
-6
Gemfile.lock
Gemfile.lock
+1
-1
saas.rb
app/apis/dingtalk/api/saas.rb
+14
-1
apps_controller.rb
app/controllers/dingtalk/apps_controller.rb
+3
-3
saas_app.rb
app/models/dingtalk/model/app/saas_app.rb
+4
-0
zh.enum.yml
config/locales/zh.enum.yml
+1
-1
config.rb
lib/rails_dingtalk/config.rb
+2
-0
No files found.
Gemfile.lock
View file @
0ebdd496
...
...
@@ -30,7 +30,7 @@ GIT
GIT
remote: https://github.com/work-design/rails_extend.git
revision:
48e8b20f65097c981b8ecc3b9b35d2082512d9e8
revision:
9f79c3ba99e3d590841736b4a7855f54035a43cc
specs:
rails_extend (1.0.0)
rails (>= 6.0)
...
...
app/apis/dingtalk/api/saas.rb
View file @
0ebdd496
...
...
@@ -7,13 +7,26 @@ module Dingtalk::Api
appkey:
app
.
app_key
,
appsecret:
app
.
app_secret
,
}
r
=
@client
.
post
'gettoken.json'
,
payload
.
to_json
,
base:
BASE
r
=
@client
.
post
'gettoken.json'
,
payload
.
to_json
,
headers:
{
},
base:
BASE
{
'access_token'
=>
r
.
dig
(
'content'
,
'data'
,
'accessToken'
),
'expires_in'
=>
r
.
dig
(
'content'
,
'data'
,
'expiresIn'
)
}
end
def
sign_header
headers
=
{
apiKey:
app
.
app_key
,
'X-Hmac-Auth-Timestamp'
:
Time
.
now
.
to_s
(
:iso8601
),
'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-IP'
:
RailsDingtalk
.
config
.
ip
,
'X-Hmac-Auth-MAC'
:
RailsDingtalk
.
config
.
mac
}
end
protected
def
with_access_token
(
params
=
{},
tries
=
2
)
yield
params
.
merge!
(
...
...
app/controllers/dingtalk/apps_controller.rb
View file @
0ebdd496
module
Dingtalk
class
AppsController
<
BaseController
before_action
:set_
new_
app
,
only:
[
:login
]
before_action
:set_app
,
only:
[
:login
]
before_action
:set_normal_app
,
only:
[
:info
]
def
info
...
...
@@ -17,8 +17,8 @@ module Dingtalk
end
private
def
set_
new_
app
@app
=
NewApp
.
find_by
(
app_key:
params
[
:app_key
])
def
set_app
@app
=
App
.
where
(
type:
[
'Dingtalk::NewApp'
,
'Dingtalk::SaasApp'
])
.
find_by
(
app_key:
params
[
:app_key
])
end
def
set_normal_app
...
...
app/models/dingtalk/model/app/saas_app.rb
View file @
0ebdd496
...
...
@@ -15,5 +15,9 @@ module Dingtalk
new_app
.
api
.
getuserinfo
(
result
[
'unionid'
])
end
def
generate_user
(
code
)
binding
.
b
end
end
end
config/locales/zh.enum.yml
View file @
0ebdd496
...
...
@@ -5,4 +5,4 @@ zh:
type
:
Dingtalk::NormalApp
:
普通App
Dingtalk::NewApp
:
NewApp
Dingtalk::SaasApp
:
政务钉
lib/rails_dingtalk/config.rb
View file @
0ebdd496
...
...
@@ -7,6 +7,8 @@ module RailsDingtalk
verify_mode:
OpenSSL
::
SSL
::
VERIFY_NONE
}
}
config
.
ip
=
'192.168.0.1'
config
.
mac
=
'fa:16:3e:27:49:91'
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