20170924054554_weibo_oauth2.rb 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. class WeiboOauth2 < ActiveRecord::Migration[4.2]
  2. def up
  3. # return if it's a new setup
  4. return if !Setting.exists?(name: 'system_init_done')
  5. Setting.create_if_not_exists(
  6. title: 'Authentication via %s',
  7. name: 'auth_weibo',
  8. area: 'Security::ThirdPartyAuthentication',
  9. description: 'Enables user authentication via %s. Register your app first at [%s](%s).',
  10. options: {
  11. form: [
  12. {
  13. display: '',
  14. null: true,
  15. name: 'auth_weibo',
  16. tag: 'boolean',
  17. options: {
  18. true => 'yes',
  19. false => 'no',
  20. },
  21. },
  22. ],
  23. },
  24. preferences: {
  25. controller: 'SettingsAreaSwitch',
  26. sub: ['auth_weibo_credentials'],
  27. title_i18n: ['Weibo'],
  28. description_i18n: ['Weibo', 'Sina Weibo Open Portal', 'http://open.weibo.com'],
  29. permission: ['admin.security'],
  30. },
  31. state: false,
  32. frontend: true
  33. )
  34. Setting.create_if_not_exists(
  35. title: 'Weibo App Credentials',
  36. name: 'auth_weibo_credentials',
  37. area: 'Security::ThirdPartyAuthentication::Weibo',
  38. description: 'Enables user authentication via Sina Weibo.',
  39. options: {
  40. form: [
  41. {
  42. display: 'App ID',
  43. null: true,
  44. name: 'app_id',
  45. tag: 'input',
  46. },
  47. {
  48. display: 'App Secret',
  49. null: true,
  50. name: 'app_secret',
  51. tag: 'input',
  52. },
  53. ],
  54. },
  55. state: {},
  56. preferences: {
  57. permission: ['admin.security'],
  58. },
  59. frontend: false
  60. )
  61. end
  62. end