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
6f0d7120
Commit
6f0d7120
authored
Sep 05, 2021
by
mingyuan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add debug info
parent
6cc6f8eb
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
17 deletions
+6
-17
apps_controller.rb
app/controllers/dingtalk/apps_controller.rb
+1
-13
new_app.rb
app/models/dingtalk/model/app/new_app.rb
+5
-4
No files found.
app/controllers/dingtalk/apps_controller.rb
View file @
6f0d7120
...
...
@@ -10,19 +10,7 @@ module Dingtalk
def
login
@dingtalk_user
=
@app
.
generate_user
(
params
[
:code
])
if
@oauth_user
.
account
.
nil?
&&
current_account
@oauth_user
.
account
=
current_account
end
@oauth_user
.
save
if
@oauth_user
.
user
login_by_oauth_user
(
@oauth_user
)
Com
::
SessionChannel
.
broadcast_to
(
params
[
:state
],
auth_token:
current_authorized_token
.
token
)
else
url_options
=
{}
url_options
.
merge!
params
.
except
(
:controller
,
:action
,
:id
,
:business
,
:namespace
,
:code
,
:state
).
permit!
url_options
.
merge!
host:
URI
(
session
[
:return_to
]).
host
if
session
[
:return_to
]
end
@dingtalk_user
.
save
end
def
create
...
...
app/models/dingtalk/model/app/new_app.rb
View file @
6f0d7120
...
...
@@ -29,11 +29,12 @@ module Dingtalk
}
r
=
HTTPX
.
post
"https://api.dingtalk.com/v1.0/oauth2/userAccessToken"
,
body:
h
.
to_json
result
=
JSON
.
parse
(
r
.
body
.
to_s
)
logger
.
debug
result
#binding.break
wechat_user
=
wechat_users
.
find_or_initialize_by
(
uid:
result
[
'openid'
])
wechat_user
.
assign_attributes
result
.
slice
(
'access_token'
,
'refresh_token'
,
'unionid'
)
wechat_user
.
expires_at
=
Time
.
current
+
result
[
'expires_in'
].
to_i
wechat_user
#
wechat_user = wechat_users.find_or_initialize_by(uid: result['openid'])
#
wechat_user.assign_attributes result.slice('access_token', 'refresh_token', 'unionid')
#
wechat_user.expires_at = Time.current + result['expires_in'].to_i
#
wechat_user
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