Merge remote-tracking branch 'origin/develop' into develop
This commit is contained in:
commit
102bd2b39e
27 changed files with 419 additions and 147 deletions
|
@ -39,13 +39,9 @@ class Index extends App.ControllerContent
|
|||
# check if auto wizard is executed
|
||||
if data.auto_wizard == true
|
||||
|
||||
# login check / get session user
|
||||
App.Auth.loginCheck()
|
||||
|
||||
if App.Config.get('system_online_service')
|
||||
@navigate 'getting_started/agents'
|
||||
else
|
||||
@navigate 'getting_started/channel'
|
||||
# show message, auto wizard is enabled
|
||||
@renderAutoWizard()
|
||||
return
|
||||
|
||||
# check if import is active
|
||||
if data.import_mode == true
|
||||
|
@ -57,11 +53,83 @@ class Index extends App.ControllerContent
|
|||
)
|
||||
|
||||
render: ->
|
||||
|
||||
@html App.view('getting_started/intro')()
|
||||
|
||||
renderAutoWizard: ->
|
||||
@html App.view('getting_started/auto_wizard_enabled')()
|
||||
|
||||
App.Config.set( 'getting_started', Index, 'Routes' )
|
||||
|
||||
|
||||
class AutoWizard extends App.ControllerContent
|
||||
className: 'getstarted fit'
|
||||
|
||||
constructor: ->
|
||||
super
|
||||
|
||||
# if already logged in, got to #
|
||||
if @authenticate(true)
|
||||
@navigate '#'
|
||||
return
|
||||
|
||||
# set title
|
||||
@title 'Auto Wizard'
|
||||
@renderSplash()
|
||||
@fetch()
|
||||
|
||||
release: =>
|
||||
@el.removeClass('fit getstarted')
|
||||
|
||||
fetch: ->
|
||||
|
||||
url = "#{@apiPath}/getting_started/auto_wizard"
|
||||
if @token
|
||||
url += "/#{@token}"
|
||||
|
||||
# get data
|
||||
@ajax(
|
||||
id: 'auto_wizard'
|
||||
type: 'GET'
|
||||
url: url
|
||||
processData: true
|
||||
success: (data, status, xhr) =>
|
||||
console.log('DDD', data)
|
||||
# redirect to login if master user already exists
|
||||
if @Config.get('system_init_done')
|
||||
@navigate '#login'
|
||||
return
|
||||
|
||||
# check if auto wizard enabled
|
||||
if data.auto_wizard is false
|
||||
@navigate '#'
|
||||
return
|
||||
|
||||
if data.auto_wizard_success is false
|
||||
if data.message
|
||||
@renderFailed(data)
|
||||
else
|
||||
@renderToken()
|
||||
return
|
||||
|
||||
# login check / get session user
|
||||
App.Auth.loginCheck()
|
||||
@navigate '#'
|
||||
return
|
||||
)
|
||||
|
||||
renderFailed: (data) ->
|
||||
@html App.view('getting_started/auto_wizard_failed')(data)
|
||||
|
||||
renderSplash: ->
|
||||
@html App.view('getting_started/auto_wizard_splash')()
|
||||
|
||||
renderToken: ->
|
||||
@html App.view('getting_started/auto_wizard_enabled')()
|
||||
|
||||
App.Config.set( 'getting_started/auto_wizard', AutoWizard, 'Routes' )
|
||||
App.Config.set( 'getting_started/auto_wizard/:token', AutoWizard, 'Routes' )
|
||||
|
||||
|
||||
class Admin extends App.ControllerContent
|
||||
className: 'getstarted fit'
|
||||
events:
|
||||
|
|
|
@ -212,7 +212,7 @@ class Singleton extends Base
|
|||
(data, status, xhr) =>
|
||||
|
||||
Ajax.disable =>
|
||||
unless Spine.isBlank(data) or @record.destroyed
|
||||
unless data is undefined or Object.getOwnPropertyNames(data).length == 0 or @record.destroyed
|
||||
# Update with latest data
|
||||
@record.refresh(data)
|
||||
|
||||
|
|
|
@ -2,6 +2,13 @@ Spine = @Spine or require('spine')
|
|||
|
||||
Spine.Model.Local =
|
||||
extended: ->
|
||||
testLocalStorage = 'spine' + new Date().getTime()
|
||||
try
|
||||
localStorage.setItem(testLocalStorage, testLocalStorage)
|
||||
localStorage.removeItem(testLocalStorage)
|
||||
catch e
|
||||
return
|
||||
|
||||
@change @saveLocal
|
||||
@fetch @loadLocal
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
Spine = @Spine or require('spine')
|
||||
isArray = Spine.isArray
|
||||
|
||||
class Collection extends Spine.Module
|
||||
constructor: (options = {}) ->
|
||||
|
@ -42,7 +41,7 @@ class Collection extends Spine.Module
|
|||
for match, i in @model.records when match.id is record.id
|
||||
@model.records.splice(i, 1)
|
||||
break
|
||||
values = [values] unless isArray(values)
|
||||
values = [values] unless Array.isArray(values)
|
||||
for record in values
|
||||
record.newRecord = false
|
||||
record[@fkey] = @record.id
|
||||
|
@ -104,7 +103,7 @@ underscore = (str) ->
|
|||
str.replace(/::/g, '/')
|
||||
.replace(/([A-Z]+)([A-Z][a-z])/g, '$1_$2')
|
||||
.replace(/([a-z\d])([A-Z])/g, '$1_$2')
|
||||
.replace(/-/g, '_')
|
||||
.replace(/(-|\.)/g, '_')
|
||||
.toLowerCase()
|
||||
|
||||
requireModel = (model) ->
|
||||
|
|
|
@ -160,19 +160,22 @@ class Model extends Module
|
|||
|
||||
@exists: (id) -> Boolean @irecords[id]
|
||||
|
||||
@addRecord: (record) ->
|
||||
@addRecord: (record,idx) ->
|
||||
if root = @irecords[record.id or record.cid]
|
||||
root.refresh(record)
|
||||
else
|
||||
record.id or= record.cid
|
||||
@irecords[record.id] = @irecords[record.cid] = record
|
||||
if idx isnt undefined
|
||||
@records.splice(idx,0,record)
|
||||
else
|
||||
@records.push(record)
|
||||
record
|
||||
|
||||
@refresh: (values, options = {}) ->
|
||||
@deleteAll() if options.clear
|
||||
records = @fromJSON(values)
|
||||
records = [records] unless isArray(records)
|
||||
records = [records] unless Array.isArray(records)
|
||||
@addRecord(record) for record in records
|
||||
@sort()
|
||||
|
||||
|
@ -256,7 +259,7 @@ class Model extends Module
|
|||
if typeof objects is 'string'
|
||||
objects = JSON.parse(objects)
|
||||
objects = @beforeFromJSON(objects)
|
||||
if isArray(objects)
|
||||
if Array.isArray(objects)
|
||||
for value in objects
|
||||
if value instanceof this
|
||||
value
|
||||
|
@ -464,7 +467,7 @@ class Model extends Module
|
|||
@id or= @cid
|
||||
|
||||
record = @dup(false)
|
||||
@constructor.addRecord(record)
|
||||
@constructor.addRecord(record,options.idx)
|
||||
@constructor.sort()
|
||||
|
||||
clone = record.clone()
|
||||
|
@ -610,14 +613,6 @@ createObject = Object.create or (o) ->
|
|||
Func.prototype = o
|
||||
new Func()
|
||||
|
||||
isArray = (value) ->
|
||||
Object::toString.call(value) is '[object Array]'
|
||||
|
||||
isBlank = (value) ->
|
||||
return true unless value
|
||||
return false for key of value
|
||||
true
|
||||
|
||||
makeArray = (args) ->
|
||||
Array::slice.call(args, 0)
|
||||
|
||||
|
@ -626,9 +621,7 @@ makeArray = (args) ->
|
|||
Spine = @Spine = {}
|
||||
module?.exports = Spine
|
||||
|
||||
Spine.version = '1.4.1'
|
||||
Spine.isArray = isArray
|
||||
Spine.isBlank = isBlank
|
||||
Spine.version = '1.5.0'
|
||||
Spine.$ = $
|
||||
Spine.Events = Events
|
||||
Spine.Log = Log
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
<% if @edit: %>
|
||||
<div class="btn btn--action" data-type="settings"><%- @T('Options') %></div>
|
||||
<% end %>
|
||||
<!--
|
||||
<ul class="pagination">
|
||||
<% for item in @view_modes: %>
|
||||
<li class="<%= item.class %>">
|
||||
|
@ -15,6 +16,7 @@
|
|||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
-->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
<div class="main flex vertical centered darkBackground">
|
||||
<img class="zammad full logo" src="<%= @C('image_path') + '/' + 'full logo on dark.svg' %>" alt="Zammad">
|
||||
<div class="setup wizard">
|
||||
<div class="wizard-slide">
|
||||
<div class="wizard-body vertical centered">
|
||||
<%- @T('The auto wizard is enabled, please use the prodvided auto wizard url.') %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
|
@ -0,0 +1,10 @@
|
|||
<div class="main flex vertical centered darkBackground">
|
||||
<img class="zammad full logo" src="<%= @C('image_path') + '/' + 'full logo on dark.svg' %>" alt="Zammad">
|
||||
<div class="setup wizard">
|
||||
<div class="wizard-slide">
|
||||
<div class="wizard-body vertical centered">
|
||||
<%- @T(@message) %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
|
@ -0,0 +1,3 @@
|
|||
<div class="main flex vertical centered darkBackground">
|
||||
<img class="zammad full logo" src="<%= @C('image_path') + '/' + 'full logo on dark.svg' %>" alt="Zammad">
|
||||
</div>
|
|
@ -35,24 +35,7 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
|
|||
return if setup_done_response
|
||||
|
||||
# check it auto wizard is already done
|
||||
auto_wizard_admin = AutoWizard.setup
|
||||
if auto_wizard_admin
|
||||
|
||||
# set current session user
|
||||
current_user_set(auto_wizard_admin)
|
||||
|
||||
# set system init to done
|
||||
Setting.set( 'system_init_done', true )
|
||||
|
||||
render json: {
|
||||
auto_wizard: true,
|
||||
setup_done: setup_done,
|
||||
import_mode: Setting.get('import_mode'),
|
||||
import_backend: Setting.get('import_backend'),
|
||||
system_online_service: Setting.get('system_online_service'),
|
||||
}
|
||||
return
|
||||
end
|
||||
return if auto_wizard_enabled_response
|
||||
|
||||
# if master user already exists, we need to be authenticated
|
||||
if setup_done
|
||||
|
@ -68,6 +51,62 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
|
|||
}
|
||||
end
|
||||
|
||||
def auto_wizard_admin
|
||||
|
||||
# check if system setup is already done
|
||||
return if setup_done_response
|
||||
|
||||
# check it auto wizard is enabled
|
||||
if !AutoWizard.enabled?
|
||||
render json: {
|
||||
auto_wizard: false,
|
||||
}
|
||||
return
|
||||
end
|
||||
|
||||
# verify auto wizard file
|
||||
auto_wizard_data = AutoWizard.data
|
||||
if !auto_wizard_data || auto_wizard_data.empty?
|
||||
render json: {
|
||||
auto_wizard: true,
|
||||
auto_wizard_success: false,
|
||||
message: 'Invalid auto wizard file.',
|
||||
}
|
||||
return
|
||||
end
|
||||
|
||||
# verify auto wizard token
|
||||
if auto_wizard_data['Token'] && auto_wizard_data['Token'] != params[:token]
|
||||
render json: {
|
||||
auto_wizard: true,
|
||||
auto_wizard_success: false,
|
||||
}
|
||||
return
|
||||
end
|
||||
|
||||
# execute auto wizard
|
||||
auto_wizard_admin = AutoWizard.setup
|
||||
if !auto_wizard_admin
|
||||
render json: {
|
||||
auto_wizard: true,
|
||||
auto_wizard_success: false,
|
||||
message: 'Error during execution of auto wizard.',
|
||||
}
|
||||
return
|
||||
end
|
||||
|
||||
# set current session user
|
||||
current_user_set(auto_wizard_admin)
|
||||
|
||||
# set system init to done
|
||||
Setting.set('system_init_done', true)
|
||||
|
||||
render json: {
|
||||
auto_wizard: true,
|
||||
auto_wizard_success: true,
|
||||
}
|
||||
end
|
||||
|
||||
def base
|
||||
|
||||
# check admin permissions
|
||||
|
@ -903,6 +942,15 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
|
|||
mxs
|
||||
end
|
||||
|
||||
def auto_wizard_enabled_response
|
||||
return false if !AutoWizard.enabled?
|
||||
|
||||
render json: {
|
||||
auto_wizard: true
|
||||
}
|
||||
true
|
||||
end
|
||||
|
||||
def setup_done
|
||||
#return false
|
||||
count = User.all.count()
|
||||
|
@ -914,9 +962,7 @@ curl http://localhost/api/v1/getting_started -v -u #{login}:#{password}
|
|||
end
|
||||
|
||||
def setup_done_response
|
||||
if !setup_done
|
||||
return false
|
||||
end
|
||||
return false if !setup_done
|
||||
|
||||
# get all groups
|
||||
groups = Group.where( active: true )
|
||||
|
|
|
@ -30,12 +30,11 @@ returns
|
|||
end
|
||||
|
||||
return data if !self['created_by_id'] && !self['updated_by_id']
|
||||
%w(created_by_id updated_by_id).each {|item|
|
||||
next if !self[ item ]
|
||||
if !data[ User.to_app_model ] || !data[ User.to_app_model ][ self[ item ] ]
|
||||
user = User.lookup( id: self[ item ] )
|
||||
%w(created_by_id updated_by_id).each {|local_user_id|
|
||||
next if !self[ local_user_id ]
|
||||
next data[ User.to_app_model ] && data[ User.to_app_model ][ self[ local_user_id ] ]
|
||||
user = User.lookup( id: self[ local_user_id ] )
|
||||
data = user.assets( data )
|
||||
end
|
||||
}
|
||||
data
|
||||
end
|
||||
|
|
|
@ -32,20 +32,19 @@ returns
|
|||
if !data[ Organization.to_app_model ][ id ]
|
||||
data[ Organization.to_app_model ][ id ] = attributes_with_associations
|
||||
if data[ Organization.to_app_model ][ id ]['member_ids']
|
||||
data[ Organization.to_app_model ][ id ]['member_ids'].each {|user_id|
|
||||
if !data[ User.to_app_model ][ user_id ]
|
||||
user = User.lookup( id: user_id )
|
||||
data[ Organization.to_app_model ][ id ]['member_ids'].each {|local_user_id|
|
||||
if !data[ User.to_app_model ][ local_user_id ]
|
||||
user = User.lookup( id: local_user_id )
|
||||
data = user.assets( data )
|
||||
end
|
||||
}
|
||||
end
|
||||
end
|
||||
%w(created_by_id updated_by_id).each {|item|
|
||||
next if !self[ item ]
|
||||
if !data[ User.to_app_model ][ self[ item ] ]
|
||||
user = User.lookup( id: self[ item ] )
|
||||
%w(created_by_id updated_by_id).each {|local_user_id|
|
||||
next if !self[ local_user_id ]
|
||||
next if data[ User.to_app_model ][ self[ local_user_id ] ]
|
||||
user = User.lookup( id: self[ local_user_id ] )
|
||||
data = user.assets( data )
|
||||
end
|
||||
}
|
||||
data
|
||||
end
|
||||
|
|
|
@ -152,6 +152,10 @@ returns
|
|||
result.push ticket
|
||||
}
|
||||
|
||||
# we do not have an destructor at this point, so we need to
|
||||
# execute ticket events manually
|
||||
Observer::Ticket::Notification.transaction
|
||||
|
||||
result
|
||||
end
|
||||
|
||||
|
|
|
@ -41,12 +41,11 @@ returns
|
|||
data[ Ticket::Article.to_app_model ][ id ]['attachments'] = attachments
|
||||
end
|
||||
|
||||
%w(created_by_id updated_by_id).each {|item|
|
||||
next if !self[ item ]
|
||||
if !data[ User.to_app_model ] || !data[ User.to_app_model ][ self[ item ] ]
|
||||
user = User.lookup( id: self[ item ] )
|
||||
%w(created_by_id updated_by_id).each {|local_user_id|
|
||||
next if !self[ local_user_id ]
|
||||
next if data[ User.to_app_model ] && data[ User.to_app_model ][ self[ local_user_id ] ]
|
||||
user = User.lookup( id: self[ local_user_id ] )
|
||||
data = user.assets( data )
|
||||
end
|
||||
}
|
||||
data
|
||||
end
|
||||
|
|
|
@ -29,12 +29,11 @@ returns
|
|||
if !data[ Ticket.to_app_model ][ id ]
|
||||
data[ Ticket.to_app_model ][ id ] = attributes_with_associations
|
||||
end
|
||||
%w(created_by_id updated_by_id owner_id customer_id).each {|item|
|
||||
next if !self[ item ]
|
||||
if !data[ User.to_app_model ] || !data[ User.to_app_model ][ self[ item ] ]
|
||||
user = User.lookup( id: self[ item ] )
|
||||
%w(created_by_id updated_by_id owner_id customer_id).each {|local_user_id|
|
||||
next if !self[ local_user_id ]
|
||||
next if data[ User.to_app_model ] && data[ User.to_app_model ][ self[ local_user_id ] ]
|
||||
user = User.lookup( id: self[ local_user_id ] )
|
||||
data = user.assets( data )
|
||||
end
|
||||
}
|
||||
data
|
||||
end
|
||||
|
|
|
@ -74,12 +74,11 @@ returns
|
|||
data = organization.assets( data )
|
||||
end
|
||||
end
|
||||
%w(created_by_id updated_by_id).each {|item|
|
||||
next if !self[ item ]
|
||||
if !data[ User.to_app_model ][ self[ item ] ]
|
||||
user = User.lookup( id: self[ item ] )
|
||||
%w(created_by_id updated_by_id).each {|local_user_id|
|
||||
next if !self[ local_user_id ]
|
||||
next if data[ User.to_app_model ][ self[ local_user_id ] ]
|
||||
user = User.lookup( id: self[ local_user_id ] )
|
||||
data = user.assets( data )
|
||||
end
|
||||
}
|
||||
data
|
||||
end
|
||||
|
|
|
@ -3,6 +3,8 @@ Zammad::Application.routes.draw do
|
|||
|
||||
# getting_started
|
||||
match api_path + '/getting_started', to: 'getting_started#index', via: :get
|
||||
match api_path + '/getting_started/auto_wizard/:token', to: 'getting_started#auto_wizard_admin', via: :get
|
||||
match api_path + '/getting_started/auto_wizard', to: 'getting_started#auto_wizard_admin', via: :get
|
||||
match api_path + '/getting_started/base', to: 'getting_started#base', via: :post
|
||||
match api_path + '/getting_started/email_probe', to: 'getting_started#email_probe', via: :post
|
||||
match api_path + '/getting_started/email_outbound', to: 'getting_started#email_outbound', via: :post
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
{
|
||||
"Token": "secret_token",
|
||||
"Users": [
|
||||
{
|
||||
"login": "hans.atila@zammad.org",
|
||||
"firstname": "Hans",
|
||||
"lastname": "Atila",
|
||||
"email": "hans.atila@zammad.org",
|
||||
"organization": "Demo Organization",
|
||||
"password": "Z4mm4dr0ckZ!"
|
||||
}
|
||||
],
|
||||
|
@ -24,8 +26,35 @@
|
|||
],
|
||||
"EmailAddresses": [
|
||||
{
|
||||
"id": 1,
|
||||
"realname": "Zammad Demo System",
|
||||
"email": "zammad_demo@localhost"
|
||||
}
|
||||
],
|
||||
"Organizations": [
|
||||
{
|
||||
"name": "Demo Organization"
|
||||
}
|
||||
],
|
||||
"Signatures": [
|
||||
{
|
||||
"id": 1,
|
||||
"name": "default",
|
||||
"body": "\n #{user.firstname} #{user.lastname}\n\n--\n Demo Organization\n--"
|
||||
}
|
||||
],
|
||||
"Channels": [
|
||||
{
|
||||
"area": "Email::Inbound",
|
||||
"adapter": "IMAP",
|
||||
"group_id": 1,
|
||||
"options": {
|
||||
"host": "mx1.example.com",
|
||||
"user": "some user",
|
||||
"password": "some pw",
|
||||
"ssl": true
|
||||
},
|
||||
"active":false
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
require 'scheduler'
|
||||
require 'ticket/state'
|
||||
class ProcessPendingTickets < ActiveRecord::Migration
|
||||
def up
|
||||
|
||||
|
@ -7,11 +5,14 @@ class ProcessPendingTickets < ActiveRecord::Migration
|
|||
pending_close_state = Ticket::State.find_by(
|
||||
name: 'pending close',
|
||||
)
|
||||
|
||||
if pending_close_state
|
||||
closed_state = Ticket::State.find_by(
|
||||
name: 'closed',
|
||||
)
|
||||
pending_close_state.next_state_id = closed_state.id
|
||||
pending_close_state.save!
|
||||
end
|
||||
|
||||
# add Ticket.process_pending
|
||||
Scheduler.create_or_update(
|
||||
|
|
|
@ -970,7 +970,7 @@ Setting.create_if_not_exists(
|
|||
},
|
||||
],
|
||||
},
|
||||
state: 'SystemAddressName',
|
||||
state: 'AgentNameSystemAddressName',
|
||||
frontend: false
|
||||
)
|
||||
|
||||
|
@ -1366,7 +1366,7 @@ Ticket::State.create_if_not_exists( id: 3, name: 'pending reminder', state_type_
|
|||
Ticket::State.create_if_not_exists( id: 4, name: 'closed', state_type_id: Ticket::StateType.where(name: 'closed').first.id )
|
||||
Ticket::State.create_if_not_exists( id: 5, name: 'merged', state_type_id: Ticket::StateType.where(name: 'merged').first.id )
|
||||
Ticket::State.create_if_not_exists( id: 6, name: 'removed', state_type_id: Ticket::StateType.where(name: 'removed').first.id, active: false )
|
||||
Ticket::State.create_if_not_exists( id: 7, name: 'pending close', state_type_id: Ticket::StateType.where(name: 'pending action').first.id, next_state_id: 5 )
|
||||
Ticket::State.create_if_not_exists( id: 7, name: 'pending close', state_type_id: Ticket::StateType.where(name: 'pending action').first.id, next_state_id: 4 )
|
||||
|
||||
Ticket::Priority.create_if_not_exists( id: 1, name: '1 low' )
|
||||
Ticket::Priority.create_if_not_exists( id: 2, name: '2 normal' )
|
||||
|
|
|
@ -1,16 +1,14 @@
|
|||
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||
|
||||
module Auth::Developer
|
||||
def self.check( _username, password, _config, user )
|
||||
def self.check(username, password, _config, user)
|
||||
|
||||
# development systems
|
||||
if Setting.get('developer_mode') == true
|
||||
if password == 'test'
|
||||
return false if !username
|
||||
return false if !user
|
||||
return false if Setting.get('developer_mode') != true
|
||||
return false if password != 'test'
|
||||
Rails.logger.info "System in developer mode, authentication for user #{user.login} ok."
|
||||
return user
|
||||
end
|
||||
end
|
||||
|
||||
false
|
||||
user
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
||||
|
||||
module Auth::Internal
|
||||
def self.check( _username, password, _config, user )
|
||||
def self.check(username, password, _config, user)
|
||||
|
||||
# return if no user exists
|
||||
return nil if !user
|
||||
return false if !username
|
||||
return false if !user
|
||||
|
||||
# sha auth check
|
||||
if user.password =~ /^\{sha2\}/
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
require 'net/ldap'
|
||||
|
||||
module Auth::Ldap
|
||||
def self.check( username, password, config, user )
|
||||
def self.check(username, password, config, user)
|
||||
|
||||
scope = Net::LDAP::SearchScope_WholeSubtree
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
require 'import/otrs'
|
||||
|
||||
module Auth::Otrs
|
||||
def self.check( username, password, config, user )
|
||||
def self.check(username, password, config, user)
|
||||
|
||||
endpoint = Setting.get('import_otrs_endpoint')
|
||||
return false if !endpoint
|
||||
|
@ -11,17 +11,17 @@ module Auth::Otrs
|
|||
return false if endpoint == 'http://otrs_host/otrs'
|
||||
|
||||
# connect to OTRS
|
||||
result = Import::OTRS.auth( username, password )
|
||||
result = Import::OTRS.auth(username, password)
|
||||
return false if !result
|
||||
return false if !result['groups_ro']
|
||||
return false if !result['groups_rw']
|
||||
return false if !result['user']
|
||||
|
||||
user = User.where( login: result['user']['UserLogin'], active: true ).first
|
||||
user = User.where(login: result['user']['UserLogin'], active: true).first
|
||||
return false if !user
|
||||
|
||||
# sync / check permissions
|
||||
Import::OTRS.permission_sync( user, result, config )
|
||||
Import::OTRS.permission_sync(user, result, config)
|
||||
|
||||
user
|
||||
end
|
||||
|
|
|
@ -2,6 +2,42 @@ module AutoWizard
|
|||
|
||||
=begin
|
||||
|
||||
check if auto wizard is enabled
|
||||
|
||||
AutoWizard.enabled?
|
||||
|
||||
returns
|
||||
|
||||
true | false
|
||||
|
||||
=end
|
||||
|
||||
def self.enabled?
|
||||
auto_wizard_file_location = file_location
|
||||
return false if !File.file?(auto_wizard_file_location)
|
||||
true
|
||||
end
|
||||
|
||||
=begin
|
||||
|
||||
get auto wizard data
|
||||
|
||||
AutoWizard.data
|
||||
|
||||
returns
|
||||
|
||||
content of auto wizard file as object
|
||||
|
||||
=end
|
||||
|
||||
def self.data
|
||||
auto_wizard_file_location = file_location
|
||||
fail "So such file #{auto_wizard_file_location}" if !File.file?(auto_wizard_file_location)
|
||||
JSON.parse( File.read(auto_wizard_file_location) )
|
||||
end
|
||||
|
||||
=begin
|
||||
|
||||
creates or updates Users, EmailAddresses and sets Settings based on the 'auto_wizard.json' file placed in the root directory.
|
||||
|
||||
there is an example file 'contrib/auto_wizard_example.json'
|
||||
|
@ -19,17 +55,35 @@ returns
|
|||
=end
|
||||
|
||||
def self.setup
|
||||
auto_wizard_file_location = file_location
|
||||
|
||||
auto_wizard_file_name = 'auto_wizard.json'
|
||||
auto_wizard_file_name = "#{Rails.root}/#{auto_wizard_file_name}"
|
||||
auto_wizard_hash = data
|
||||
|
||||
return if !File.file?(auto_wizard_file_name)
|
||||
admin_user = User.find(1)
|
||||
|
||||
auto_wizard_file = File.read(auto_wizard_file_name)
|
||||
# set Settings
|
||||
if auto_wizard_hash['Settings']
|
||||
auto_wizard_hash['Settings'].each { |setting_data|
|
||||
Setting.set( setting_data['name'], setting_data['value'] )
|
||||
}
|
||||
end
|
||||
|
||||
auto_wizard_hash = JSON.parse(auto_wizard_file)
|
||||
# create Organizations
|
||||
if auto_wizard_hash['Organizations']
|
||||
auto_wizard_hash['Organizations'].each { |organization_data|
|
||||
|
||||
admin_user = User.find( 1 )
|
||||
organization_data_symbolized = organization_data.symbolize_keys.merge(
|
||||
{
|
||||
updated_by_id: admin_user.id,
|
||||
created_by_id: admin_user.id
|
||||
}
|
||||
)
|
||||
|
||||
Organization.create_or_update(
|
||||
organization_data_symbolized
|
||||
)
|
||||
}
|
||||
end
|
||||
|
||||
# create Users
|
||||
if auto_wizard_hash['Users']
|
||||
|
@ -39,9 +93,16 @@ returns
|
|||
|
||||
auto_wizard_hash['Users'].each { |user_data|
|
||||
|
||||
user_data_symbolized = user_data.symbolize_keys
|
||||
# lookup organization
|
||||
if user_data['organization'] && !user_data['organization'].empty?
|
||||
organization = Organization.find_by(name: user_data['organization'])
|
||||
user_data.delete('organization')
|
||||
if organization
|
||||
user_data['organization_id'] = organization.id
|
||||
end
|
||||
end
|
||||
|
||||
user_data_symbolized = user_data_symbolized.merge(
|
||||
user_data_symbolized = user_data.symbolize_keys.merge(
|
||||
{
|
||||
active: true,
|
||||
roles: roles,
|
||||
|
@ -62,34 +123,45 @@ returns
|
|||
}
|
||||
end
|
||||
|
||||
# set Settings
|
||||
if auto_wizard_hash['Settings']
|
||||
|
||||
auto_wizard_hash['Settings'].each { |setting_data|
|
||||
Setting.set( setting_data['name'], setting_data['value'] )
|
||||
# create EmailAddresses/Channels/Signatures
|
||||
model_map = {
|
||||
'EmailAddresses' => 'EmailAddress',
|
||||
'Channels' => 'Channel',
|
||||
'Signatures' => 'Signature',
|
||||
}
|
||||
end
|
||||
|
||||
# add EmailAddresses
|
||||
if auto_wizard_hash['EmailAddresses']
|
||||
|
||||
auto_wizard_hash['EmailAddresses'].each { |email_address_data|
|
||||
|
||||
email_address_data_symbolized = email_address_data.symbolize_keys
|
||||
|
||||
email_address_data_symbolized = email_address_data_symbolized.merge(
|
||||
model_map.each {|map_name, model|
|
||||
next if !auto_wizard_hash[map_name]
|
||||
auto_wizard_hash[map_name].each {|data|
|
||||
data_symbolized = data.symbolize_keys.merge(
|
||||
{
|
||||
updated_by_id: admin_user.id,
|
||||
created_by_id: admin_user.id
|
||||
}
|
||||
)
|
||||
|
||||
EmailAddress.create_if_not_exists(
|
||||
email_address_data_symbolized
|
||||
if data_symbolized[:id] || data_symbolized[:name]
|
||||
Kernel.const_get(model).create_or_update(
|
||||
data_symbolized
|
||||
)
|
||||
else
|
||||
Kernel.const_get(model).create(
|
||||
data_symbolized
|
||||
)
|
||||
}
|
||||
end
|
||||
}
|
||||
}
|
||||
|
||||
# remove auto wizard file
|
||||
FileUtils.rm auto_wizard_file_location
|
||||
|
||||
admin_user
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def self.file_location
|
||||
auto_wizard_file_name = 'auto_wizard.json'
|
||||
auto_wizard_file_location = "#{Rails.root}/#{auto_wizard_file_name}"
|
||||
auto_wizard_file_location
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,11 +8,19 @@ class AutoWizardTest < TestCase
|
|||
|
||||
watch_for(
|
||||
css: 'body',
|
||||
value: 'Invite',
|
||||
value: 'auto wizard is enabled',
|
||||
timeout: 10,
|
||||
)
|
||||
|
||||
click( css: '.content .btn--primary' )
|
||||
location( url: "#{browser_url}/#getting_started/auto_wizard" )
|
||||
|
||||
watch_for(
|
||||
css: 'body',
|
||||
value: 'auto wizard is enabled',
|
||||
timeout: 10,
|
||||
)
|
||||
|
||||
location( url: "#{browser_url}/#getting_started/auto_wizard/secret_token" )
|
||||
|
||||
watch_for(
|
||||
css: '.user-menu .user a',
|
||||
|
@ -21,6 +29,30 @@ class AutoWizardTest < TestCase
|
|||
timeout: 20,
|
||||
)
|
||||
|
||||
organization_open_by_search(
|
||||
value: 'Demo Organization',
|
||||
)
|
||||
watch_for(
|
||||
css: '.active .profile-window',
|
||||
value: 'Demo Organization',
|
||||
)
|
||||
watch_for(
|
||||
css: '.active .profile-window',
|
||||
value: 'Atila',
|
||||
)
|
||||
|
||||
logout
|
||||
|
||||
login(
|
||||
username: 'hans.atila@zammad.org',
|
||||
password: 'Z4mm4dr0ckZ!',
|
||||
)
|
||||
watch_for(
|
||||
css: '.user-menu .user a',
|
||||
attribute: 'title',
|
||||
value: 'hans.atila@zammad.org',
|
||||
timeout: 8,
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -165,7 +165,7 @@ class TicketTest < ActiveSupport::TestCase
|
|||
test 'ticket process_pending' do
|
||||
|
||||
ticket = Ticket.create(
|
||||
title: "pending close test",
|
||||
title: 'pending close test',
|
||||
group: Group.lookup( name: 'Users'),
|
||||
customer_id: 2,
|
||||
state: Ticket::State.lookup( name: 'pending close' ),
|
||||
|
@ -179,7 +179,7 @@ class TicketTest < ActiveSupport::TestCase
|
|||
|
||||
assert_equal( lookup_ticket.id, ticket.id, 'ticket.pending_time verify' )
|
||||
|
||||
Ticket.process_pending()
|
||||
Ticket.process_pending
|
||||
|
||||
lookup_ticket = Ticket.find_by( 'pending_time <= ?', Time.zone.now )
|
||||
|
||||
|
|
Loading…
Reference in a new issue