Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Conflicts: config/routes.rb db/migrate/20080819180845_create_clients.rb
- Loading branch information
Showing
34 changed files
with
880 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
class RadchecksController < ApplicationController | ||
before_filter :login_required | ||
layout nil | ||
|
||
def create | ||
@radcheck = Radcheck.new(params[:radcheck]) | ||
if @radcheck.save | ||
flash[:notice] = "Dialup account created successfully!" | ||
redirect_to :back | ||
else | ||
flash[:notice] = "Suite could not create this dialup account." | ||
redirect_to :back | ||
end | ||
end | ||
|
||
def update | ||
@radcheck = Radcheck.find(params[:id]) | ||
if @radcheck.update_attributes(params[:radcheck]) | ||
flash[:notice] = "Dialup account updated successfully!" | ||
redirect_to :back | ||
else | ||
flash[:notice] = "Suite could not update this dialup account." | ||
redirect_to :back | ||
end | ||
end | ||
|
||
def destroy | ||
@radcheck = Radcheck.find(params[:id]) | ||
if @radcheck.destroy | ||
flash[:notice] = "Dialup account deleted successfully." | ||
redirect_to :back | ||
else | ||
flash[:notice] = "Dialup account could not be deleted." | ||
redirect_to :back | ||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
class Radcheck < ActiveRecord::Base | ||
use_db :prefix => "freeradius_" | ||
set_table_name "radcheck" | ||
|
||
belongs_to :client | ||
|
||
validates_presence_of :username, :attribute, :value | ||
validates_uniqueness_of :username | ||
|
||
# this won't work for some reason | ||
before_create :set_attribute | ||
def set_attribute | ||
self.attribute = "User-Password" | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<% !@client.radcheck.blank? ? @radcheck = @client.radcheck : @radcheck = Radcheck.new %> | ||
<div id="dialup"> | ||
<% if @client.radcheck.blank? %> | ||
<ul class="toolbar"> | ||
<li><a href="#" class="add">Add Dialup</a></li> | ||
</ul> | ||
<% else %> | ||
<ul class="toolbar"> | ||
<% if @client.radcheck.value[0..8] == "disabled_" %> | ||
<li><a href="#" class="enable">Enable Dialup Account</a></li> | ||
<% else %> | ||
<li><a href="#" class="disable">Disable Dialup Account</a></li> | ||
<% end %> | ||
<li><%= link_to "Delete Dialup Account", { :controller => "radchecks", :action => "destroy", :id => @radcheck }, :confirm => "Are you sure you want to delete this dialup account?", :method => :delete %></li> | ||
</ul> | ||
<% end %> | ||
<div id="dialup_form" class="toolbox hide"> | ||
<% form_for @radcheck do |f| %> | ||
<table class="m"> | ||
<tr> | ||
<td class="first">Username:</td> | ||
<td><%= f.text_field :username %></td> | ||
</tr> | ||
<tr> | ||
<td class="first">Password:</td> | ||
<td><%= f.text_field :value %></td> | ||
</tr> | ||
</table> | ||
<%= f.hidden_field :attribute, :value => "User-Password" %> | ||
<%= f.hidden_field :client_id, :value => @client.id %> | ||
<%= f.submit "Save" %> | ||
<% end %> | ||
<br /> | ||
</div> | ||
</div> | ||
|
||
<script> | ||
<% if @client.active_dialup_user? %> | ||
$("div#dialup_form").removeClass("hide"); | ||
$("div#dialup a.disable").click(function(){ | ||
var password = $("input#radcheck_value").val(); | ||
password = "disabled_" + password; | ||
$("input#radcheck_value").val(password); | ||
$("div#dialup_form form input[type=submit]").click(); | ||
}); | ||
<% else %> | ||
$("div#dialup a.enable").click(function(){ | ||
var password = $("input#radcheck_value").val(); | ||
password = password.split("disabled_"); | ||
password = password[1]; | ||
$("input#radcheck_value").val(password); | ||
$("div#dialup_form form input[type=submit]").click(); | ||
}); | ||
<% end %> | ||
|
||
$("div#dialup > ul.toolbar > li > a.add").click(function(){ | ||
$("div#dialup_form").slideDown(500); | ||
}); | ||
|
||
|
||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.