diff --git a/Gemfile b/Gemfile index f79ef83..28de950 100644 --- a/Gemfile +++ b/Gemfile @@ -9,6 +9,10 @@ gem 'sqlite3' gem 'thin' +gem 'devise' +gem 'omniauth' +gem 'omniauth-kerberos' + # Gems used only for assets and not required # in production environments by default. diff --git a/Gemfile.lock b/Gemfile.lock index 12dbd36..6987ab4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -29,6 +29,7 @@ GEM i18n (~> 0.6) multi_json (~> 1.0) arel (3.0.2) + bcrypt-ruby (3.0.1) better_errors (0.7.2) coderay (>= 1.0.0) erubis (>= 2.6.6) @@ -57,6 +58,11 @@ GEM commonjs (0.2.6) daemons (1.1.9) debug_inspector (0.0.2) + devise (2.2.3) + bcrypt-ruby (~> 3.0) + orm_adapter (~> 0.1) + railties (~> 3.1) + warden (~> 1.2.1) erubis (2.7.0) eventmachine (1.0.3) execjs (1.4.0) @@ -64,6 +70,7 @@ GEM fastercsv (1.5.5) haml (4.0.1) tilt + hashie (1.2.0) highline (1.6.16) hike (1.2.1) i18n (0.6.4) @@ -87,6 +94,15 @@ GEM railties mime-types (1.21) multi_json (1.7.2) + omniauth (1.1.3) + hashie (~> 1.2) + rack + omniauth-kerberos (0.2.0) + omniauth-multipassword + timfel-krb5-auth (~> 0.8) + omniauth-multipassword (0.4.0) + omniauth (~> 1.0) + orm_adapter (0.4.0) polyglot (0.3.3) rack (1.4.5) rack-cache (1.2) @@ -149,6 +165,7 @@ GEM rack (>= 1.0.0) thor (0.18.0) tilt (1.3.6) + timfel-krb5-auth (0.8) treetop (1.4.12) polyglot polyglot (>= 0.3.1) @@ -160,6 +177,8 @@ GEM uglifier (1.3.0) execjs (>= 0.3.0) multi_json (~> 1.0, >= 1.0.2) + warden (1.2.1) + rack (>= 1.0) PLATFORMS ruby @@ -169,9 +188,12 @@ DEPENDENCIES binding_of_caller brakeman coffee-rails (~> 3.2.1) + devise jquery-rails less-rails meta_request + omniauth + omniauth-kerberos rack-mini-profiler rails (= 3.2.11) rails-footnotes diff --git a/app/assets/javascripts/home.js.coffee b/app/assets/javascripts/home.js.coffee new file mode 100644 index 0000000..7615679 --- /dev/null +++ b/app/assets/javascripts/home.js.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ diff --git a/app/assets/stylesheets/home.css.scss b/app/assets/stylesheets/home.css.scss new file mode 100644 index 0000000..f0ddc68 --- /dev/null +++ b/app/assets/stylesheets/home.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the home controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/alerts_controller.rb b/app/controllers/alerts_controller.rb index e01b0ea..47d7ec7 100644 --- a/app/controllers/alerts_controller.rb +++ b/app/controllers/alerts_controller.rb @@ -1,24 +1,23 @@ class AlertsController < ApplicationController + before_filter :authenticate_user! # GET /alerts # GET /alerts.json def index - @alerts = Alert.all + @alerts = Alert.user_alerts(current_user.id) respond_to do |format| format.html # index.html.erb - format.json { render json: @alerts } end end # GET /alerts/1 # GET /alerts/1.json def show - @alert = Alert.find(params[:id]) + @alert = Alert.user_alerts(current_user.id).find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml # show.xml.builder - format.json { render json: @alert } end end @@ -29,27 +28,25 @@ class AlertsController < ApplicationController respond_to do |format| format.html # new.html.erb - format.json { render json: @alert } end end # GET /alerts/1/edit def edit - @alert = Alert.find(params[:id]) + @alert = Alert.user_alerts(current_user.id).find(params[:id]) end # POST /alerts # POST /alerts.json def create @alert = Alert.new(params[:alert]) + @alert.user_id = current_user.id respond_to do |format| if @alert.save format.html { redirect_to @alert, notice: 'Alert was successfully created.' } - format.json { render json: @alert, status: :created, location: @alert } else format.html { render action: "new" } - format.json { render json: @alert.errors, status: :unprocessable_entity } end end end @@ -57,15 +54,13 @@ class AlertsController < ApplicationController # PUT /alerts/1 # PUT /alerts/1.json def update - @alert = Alert.find(params[:id]) + @alert = Alert.user_alerts(current_user.id).find(params[:id]) respond_to do |format| if @alert.update_attributes(params[:alert]) format.html { redirect_to @alert, notice: 'Alert was successfully updated.' } - format.json { head :no_content } else format.html { render action: "edit" } - format.json { render json: @alert.errors, status: :unprocessable_entity } end end end @@ -73,12 +68,11 @@ class AlertsController < ApplicationController # DELETE /alerts/1 # DELETE /alerts/1.json def destroy - @alert = Alert.find(params[:id]) + @alert = Alert.user_alerts(current_user.id).find(params[:id]) @alert.destroy respond_to do |format| format.html { redirect_to alerts_url } - format.json { head :no_content } end end end diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb new file mode 100644 index 0000000..95f2992 --- /dev/null +++ b/app/controllers/home_controller.rb @@ -0,0 +1,4 @@ +class HomeController < ApplicationController + def index + end +end diff --git a/app/helpers/home_helper.rb b/app/helpers/home_helper.rb new file mode 100644 index 0000000..23de56a --- /dev/null +++ b/app/helpers/home_helper.rb @@ -0,0 +1,2 @@ +module HomeHelper +end diff --git a/app/models/alert.rb b/app/models/alert.rb index 3921e70..412a7a3 100644 --- a/app/models/alert.rb +++ b/app/models/alert.rb @@ -17,12 +17,16 @@ class Alert < ActiveRecord::Base :format => { :with => /\A[0-9]+[A-Za-z]?\Z/ } - validates :user_id, :presence => true, - :numericality => { - only_integer: true - } + # validates :user_id, :presence => true, + # :numericality => { + # only_integer: true + # } validates :semester, :presence => true + scope :user_alerts, lambda { |user_id| + where('Alerts.user_id = ?', user_id) + } + def alerted? @alerted end diff --git a/app/models/user.rb b/app/models/user.rb new file mode 100644 index 0000000..02543cc --- /dev/null +++ b/app/models/user.rb @@ -0,0 +1,11 @@ +class User < ActiveRecord::Base + # Include default devise modules. Others available are: + # :token_authenticatable, :confirmable, + # :lockable, :timeoutable and :omniauthable + devise :database_authenticatable, :registerable, + :recoverable, :rememberable, :trackable, :validatable + + # Setup accessible (or protected) attributes for your model + attr_accessible :email, :password, :password_confirmation, :remember_me + # attr_accessible :title, :body +end diff --git a/app/views/alerts/_form.html.erb b/app/views/alerts/_form.html.erb index 758bfe6..5937420 100644 --- a/app/views/alerts/_form.html.erb +++ b/app/views/alerts/_form.html.erb @@ -1,10 +1,4 @@ <%= form_for @alert, :html => { :class => 'form-horizontal' } do |f| %> -
Welcome <%= @email %>!
+ +You can confirm your account email through the link below:
+ +<%= link_to 'Confirm my account', confirmation_url(@resource, :confirmation_token => @resource.confirmation_token) %>
diff --git a/app/views/devise/mailer/reset_password_instructions.html.erb b/app/views/devise/mailer/reset_password_instructions.html.erb new file mode 100644 index 0000000..2713034 --- /dev/null +++ b/app/views/devise/mailer/reset_password_instructions.html.erb @@ -0,0 +1,8 @@ +Hello <%= @resource.email %>!
+ +Someone has requested a link to change your password. You can do this through the link below.
+ +<%= link_to 'Change my password', edit_password_url(@resource, :reset_password_token => @resource.reset_password_token) %>
+ +If you didn't request this, please ignore this email.
+Your password won't change until you access the link above and create a new one.
diff --git a/app/views/devise/mailer/unlock_instructions.html.erb b/app/views/devise/mailer/unlock_instructions.html.erb new file mode 100644 index 0000000..a4152e1 --- /dev/null +++ b/app/views/devise/mailer/unlock_instructions.html.erb @@ -0,0 +1,7 @@ +Hello <%= @resource.email %>!
+ +Your account has been locked due to an excessive number of unsuccessful sign in attempts.
+ +Click the link below to unlock your account:
+ +<%= link_to 'Unlock my account', unlock_url(@resource, :unlock_token => @resource.unlock_token) %>
diff --git a/app/views/devise/passwords/edit.html.erb b/app/views/devise/passwords/edit.html.erb new file mode 100644 index 0000000..34a4960 --- /dev/null +++ b/app/views/devise/passwords/edit.html.erb @@ -0,0 +1,16 @@ +Unhappy? <%= button_to "Cancel my account", registration_path(resource_name), :data => { :confirm => "Are you sure?" }, :method => :delete %>.
+ +<%= link_to "Back", :back %> diff --git a/app/views/devise/registrations/new.html.erb b/app/views/devise/registrations/new.html.erb new file mode 100644 index 0000000..3f189d4 --- /dev/null +++ b/app/views/devise/registrations/new.html.erb @@ -0,0 +1,18 @@ +Find me in app/views/home/index.html.erb
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 2534fa0..3c56e94 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -44,12 +44,20 @@ - MsuCourseAlerter + MsuCourseAlerter