Module: Omnigollum::Helpers

Defined in:
lib/omnigollum.rb

Instance Method Summary collapse

Instance Method Details

#auth_configObject



57
58
59
60
61
62
63
64
65
66
67
# File 'lib/omnigollum.rb', line 57

def auth_config
  options = settings.send(:omnigollum)
  
  @auth = {
    :route_prefix => options[:route_prefix],
    :providers    => options[:provider_names],
    :path_images  => options[:path_images],
    :logo_suffix  => options[:logo_suffix],
    :logo_missing => options[:logo_missing]
  }
end

#commit_messageObject



75
76
77
78
79
80
81
82
# File 'lib/omnigollum.rb', line 75

def commit_message
  if user_authed?
    user = get_user
    return { :message => params[:message], :name => user.name, :email => user.email}
  else
    return { :message => params[:message]}
  end
end

#get_userObject



49
50
51
# File 'lib/omnigollum.rb', line 49

def get_user
  session[:auth_user]
end

#kick_backObject



42
43
44
45
46
47
# File 'lib/omnigollum.rb', line 42

def kick_back
  redirect !request.referrer.nil? && request.referrer !~ /#{Regexp.escape(settings.send(:omnigollum)[:route_prefix])}\/.*/ ?
    request.referrer:
    '/'
  halt
end

#show_loginObject



69
70
71
72
73
# File 'lib/omnigollum.rb', line 69

def 
  auth_config
  require settings.send(:omnigollum)[:path_views] + '/login'
  halt mustache Omnigollum::Views::Login
end

#user_authObject



36
37
38
39
40
# File 'lib/omnigollum.rb', line 36

def user_auth
  @title   = 'Authentication is required'
  @subtext = 'Please choose a login service'
  
end

#user_authed?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/omnigollum.rb', line 32

def user_authed?
  session.has_key? :auth_user
end

#user_deauthObject



53
54
55
# File 'lib/omnigollum.rb', line 53

def user_deauth
  session.delete :auth_user
end