diff --git a/app/controllers/oauth2_controller.rb b/app/controllers/oauth2_controller.rb index 743596f41..1769ddd16 100644 --- a/app/controllers/oauth2_controller.rb +++ b/app/controllers/oauth2_controller.rb @@ -1,4 +1,4 @@ -class Oauth2Controller < ActionController::Base +class Oauth2Controller < ApplicationController layout 'doorkeeper/application' include LoginHelper @@ -9,6 +9,12 @@ class Oauth2Controller < ActionController::Base end def create + if User.current.logged? + to_url = params[:call_url] + "&auth=" + User.current.login + to_url = params[:call_url] + "&auth=" + User.current.login + "&state=" + params[:state] if params[:state].present? + redirect_to to_url + return + end if params[:login].blank? @error = {msg: '邮箱地址或用户名不能为空', id: 'login'} elsif params[:password].blank? diff --git a/app/views/api/v1/projects/_simple_gitea_diff_detail.json.jbuilder b/app/views/api/v1/projects/_simple_gitea_diff_detail.json.jbuilder index f313d2edd..b24342cd6 100644 --- a/app/views/api/v1/projects/_simple_gitea_diff_detail.json.jbuilder +++ b/app/views/api/v1/projects/_simple_gitea_diff_detail.json.jbuilder @@ -1,41 +1,43 @@ -json.file_nums diff['NumFiles'] -json.total_addition diff['TotalAddition'] -json.total_deletion diff['TotalDeletion'] -json.files diff['Files'].each do |file| - json.name file['Name'] - json.oldname file['OldName'] - json.addition file['Addition'] - json.deletion file['Deletion'] - json.type file['Type'] - json.is_created file['IsCreated'] - json.is_deleted file['IsDeleted'] - json.is_bin file['IsBin'] - json.is_lfs_file file['IsLFSFile'] - json.is_renamed file['IsRenamed'] - json.is_ambiguous file['IsAmbiguous'] - json.is_submodule file['IsSubmodule'] - json.diff file['Diff'] - json.sections file['Sections'] do |section| - json.file_name section['FileName'] - json.name section['Name'] - json.lines section['Lines'] do |line| - json.left_index line['LeftIdx'] - json.right_index line['RightIdx'] - json.match line['Match'] - json.type line['Type'] - json.content line['Content'] - unless line['SectionInfo'].blank? - json.section_path line['SectionInfo']['Path'] - json.section_last_left_index line['SectionInfo']['LastLeftIdx'] - json.section_last_right_index line['SectionInfo']['LastRightIdx'] - json.section_left_index line['SectionInfo']['LeftIdx'] - json.section_right_index line['SectionInfo']['RightIdx'] - json.section_left_hunk_size line['SectionInfo']['LeftHunkSize'] - json.section_right_hunk_size line['SectionInfo']['RightHunkSize'] +if diff.present? + json.file_nums diff['NumFiles'] + json.total_addition diff['TotalAddition'] + json.total_deletion diff['TotalDeletion'] + json.files diff['Files'].each do |file| + json.name file['Name'] + json.oldname file['OldName'] + json.addition file['Addition'] + json.deletion file['Deletion'] + json.type file['Type'] + json.is_created file['IsCreated'] + json.is_deleted file['IsDeleted'] + json.is_bin file['IsBin'] + json.is_lfs_file file['IsLFSFile'] + json.is_renamed file['IsRenamed'] + json.is_ambiguous file['IsAmbiguous'] + json.is_submodule file['IsSubmodule'] + json.diff file['Diff'] + json.sections file['Sections'] do |section| + json.file_name section['FileName'] + json.name section['Name'] + json.lines section['Lines'] do |line| + json.left_index line['LeftIdx'] + json.right_index line['RightIdx'] + json.match line['Match'] + json.type line['Type'] + json.content line['Content'] + unless line['SectionInfo'].blank? + json.section_path line['SectionInfo']['Path'] + json.section_last_left_index line['SectionInfo']['LastLeftIdx'] + json.section_last_right_index line['SectionInfo']['LastRightIdx'] + json.section_left_index line['SectionInfo']['LeftIdx'] + json.section_right_index line['SectionInfo']['RightIdx'] + json.section_left_hunk_size line['SectionInfo']['LeftHunkSize'] + json.section_right_hunk_size line['SectionInfo']['RightHunkSize'] + end end end + json.is_incomplete file['IsIncomplete'] + json.is_incomplete_line_too_long file['IsIncompleteLineTooLong'] + json.is_protected file['IsProtected'] end - json.is_incomplete file['IsIncomplete'] - json.is_incomplete_line_too_long file['IsIncompleteLineTooLong'] - json.is_protected file['IsProtected'] end \ No newline at end of file diff --git a/app/views/oauth2/show.html.erb b/app/views/oauth2/show.html.erb index 3718084b3..583c2dfca 100644 --- a/app/views/oauth2/show.html.erb +++ b/app/views/oauth2/show.html.erb @@ -1,26 +1,101 @@ + +<% if User.current.logged? %> +
+

+ <%= @app&.name %>客户端
+ 此第三方应用请求获得以下权限: -

-
- <%= form_tag oauth2_path, method: :post, authenticity_token: true, remote: true, class: 'login-form' do %> - <%= hidden_field_tag :client_id, @app.uid %> - <%= hidden_field_tag :call_url, @call_url %> - <%= hidden_field_tag :state, params[:state] %> -

- <%= text_field_tag :login, '', placeholder: '请输入邮箱地址/用户名' %> -

- <%= password_field_tag :password, '', placeholder: '请输入密码'%> -

- <%= submit_tag '授权登录', class: "btn btn-login btn-lg btn-block mt-20" %> - <% end %> -
- <%= link_to "注 册", '/register', class: 'reg-link' %> +

+
+
    +
  • +
    + + +
    +
  • +
  • +
    + + +
    +
  • +
+
+ +
+
+ <%= form_tag oauth2_path, method: :post, authenticity_token: true, remote: true, class: 'login-form' do %> + <%= hidden_field_tag :client_id, @app.uid %> + <%= hidden_field_tag :call_url, @call_url %> + <%= submit_tag '同意授权', class: "btn btn-login btn-lg btn-block mt-20" %> + <% end %> +
+ <%= link_to "拒绝", '/access_denied', class: 'reg-link' %> +
-
-
\ No newline at end of file + +<% else %> +
+

+ 申请使用 GitLink 账号登录 + <%= @app&.name %> +

+ +
+
+ <%= form_tag oauth2_path, method: :post, authenticity_token: true, remote: true, class: 'login-form' do %> + <%= hidden_field_tag :client_id, @app.uid %> + <%= hidden_field_tag :call_url, @call_url %> +

+ <%= text_field_tag :login, '', placeholder: '请输入邮箱地址/用户名' %> +

+ <%= password_field_tag :password, '', placeholder: '请输入密码' %> +

+ <%= submit_tag '授权登录', class: "btn btn-login btn-lg btn-block mt-20" %> + <% end %> +
+ <%= link_to "注 册", '/register', class: 'reg-link' %> +
+
+
+
+<% end %> + + + diff --git a/app/views/project_trends/_detail.json.jbuilder b/app/views/project_trends/_detail.json.jbuilder index b9febc107..20977e6a1 100644 --- a/app/views/project_trends/_detail.json.jbuilder +++ b/app/views/project_trends/_detail.json.jbuilder @@ -20,14 +20,18 @@ elsif trend.trend_type == "VersionRelease" json.partial! "version_releases/simple_version_release", locals: {version: trend.trend} elsif trend.trend_type == "CommitLog" commit_log = trend.trend - json.name commit_log.message - json.created_at format_time(commit_log.created_at) - json.commit_log do - json.user do - json.partial! 'users/user_simple', locals: {user: commit_log.user} + if commit_log.present? + json.name commit_log.message + json.created_at format_time(commit_log.created_at) + json.commit_log do + json.user do + json.partial! 'users/user_simple', locals: {user: commit_log.user} + end + json.ref commit_log.ref.to_s.gsub("refs/heads/", "") + json.extract! commit_log, :id,:name,:full_name,:message, :commit_id,:created_at,:updated_at end - json.ref commit_log.ref.to_s.gsub("refs/heads/", "") - json.extract! commit_log, :id,:name,:full_name,:message, :commit_id,:created_at,:updated_at + else + json.nil end else json.name trend.trend&.title