Skip to content

Commit

Permalink
Created user model, started working on authentication
Browse files Browse the repository at this point in the history
  • Loading branch information
Francismb committed Aug 24, 2015
1 parent 9661932 commit ca60314
Show file tree
Hide file tree
Showing 20 changed files with 272 additions and 9 deletions.
27 changes: 27 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
source 'https://rubygems.org'


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.1'

# Development gems
group :development do
# Use sqlite3 as a development database
gem 'sqlite3'
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
# gem 'tzinfo-data', platforms: [:mingw, :mswin]
end

# production gems
group :production do
gem 'pg'
end

# Use carrierwave for the product image handling
# gem 'carrierwave'

# Use jquery as the JavaScript library
gem 'jquery-rails'

# Use ActiveModel has_secure_password
gem 'bcrypt', '~> 3.1.7'
118 changes: 118 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
GEM
remote: https://rubygems.org/
specs:
actionmailer (4.2.1)
actionpack (= 4.2.1)
actionview (= 4.2.1)
activejob (= 4.2.1)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 1.0, >= 1.0.5)
actionpack (4.2.1)
actionview (= 4.2.1)
activesupport (= 4.2.1)
rack (~> 1.6)
rack-test (~> 0.6.2)
rails-dom-testing (~> 1.0, >= 1.0.5)
rails-html-sanitizer (~> 1.0, >= 1.0.1)
actionview (4.2.1)
activesupport (= 4.2.1)
builder (~> 3.1)
erubis (~> 2.7.0)
rails-dom-testing (~> 1.0, >= 1.0.5)
rails-html-sanitizer (~> 1.0, >= 1.0.1)
activejob (4.2.1)
activesupport (= 4.2.1)
globalid (>= 0.3.0)
activemodel (4.2.1)
activesupport (= 4.2.1)
builder (~> 3.1)
activerecord (4.2.1)
activemodel (= 4.2.1)
activesupport (= 4.2.1)
arel (~> 6.0)
activesupport (4.2.1)
i18n (~> 0.7)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
arel (6.0.1)
bcrypt (3.1.10)
bcrypt (3.1.10-x86-mingw32)
builder (3.2.2)
erubis (2.7.0)
globalid (0.3.5)
activesupport (>= 4.1.0)
i18n (0.7.0)
jquery-rails (4.0.4)
rails-dom-testing (~> 1.0)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
json (1.8.3)
loofah (2.0.2)
nokogiri (>= 1.5.9)
mail (2.6.3)
mime-types (>= 1.16, < 3)
mime-types (2.6.1)
mini_portile (0.6.2)
minitest (5.7.0)
nokogiri (1.6.6.2)
mini_portile (~> 0.6.0)
nokogiri (1.6.6.2-x86-mingw32)
mini_portile (~> 0.6.0)
pg (0.18.2)
pg (0.18.2-x86-mingw32)
rack (1.6.4)
rack-test (0.6.3)
rack (>= 1.0)
rails (4.2.1)
actionmailer (= 4.2.1)
actionpack (= 4.2.1)
actionview (= 4.2.1)
activejob (= 4.2.1)
activemodel (= 4.2.1)
activerecord (= 4.2.1)
activesupport (= 4.2.1)
bundler (>= 1.3.0, < 2.0)
railties (= 4.2.1)
sprockets-rails
rails-deprecated_sanitizer (1.0.3)
activesupport (>= 4.2.0.alpha)
rails-dom-testing (1.0.6)
activesupport (>= 4.2.0.beta, < 5.0)
nokogiri (~> 1.6.0)
rails-deprecated_sanitizer (>= 1.0.1)
rails-html-sanitizer (1.0.2)
loofah (~> 2.0)
railties (4.2.1)
actionpack (= 4.2.1)
activesupport (= 4.2.1)
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (10.4.2)
sprockets (3.2.0)
rack (~> 1.0)
sprockets-rails (2.3.2)
actionpack (>= 3.0)
activesupport (>= 3.0)
sprockets (>= 2.8, < 4.0)
sqlite3 (1.3.10)
sqlite3 (1.3.10-x86-mingw32)
thor (0.19.1)
thread_safe (0.3.5)
tzinfo (1.2.2)
thread_safe (~> 0.1)

PLATFORMS
ruby
x86-mingw32

DEPENDENCIES
bcrypt (~> 3.1.7)
jquery-rails
pg
rails (= 4.2.1)
sqlite3

BUNDLED WITH
1.10.6
Binary file added app/assets/images/border.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions app/assets/javascripts/access.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Place all the behaviors and hooks related to the matching controller here.
// All this logic will automatically be available in application.js.
4 changes: 4 additions & 0 deletions app/assets/stylesheets/access.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/*
Place all the styles related to the matching controller here.
They will automatically be included in application.css.
*/
8 changes: 6 additions & 2 deletions app/assets/stylesheets/generic.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ body {
font-family: 'Open Sans', arial, sans-serif;
}
h1, h2, h3 {
font-weight: lighter;
color: #333333;
}
a {
Expand All @@ -23,6 +24,7 @@ a {
}
.content {
margin-top: 50px;
font-weight: 300;
}

.center {
Expand Down Expand Up @@ -85,11 +87,13 @@ a {
color: #f44336;
}
.header > ul.menu > li:nth-of-type(3) > a:hover, .header > ul.menu > li:nth-of-type(3) > a:focus, .header > ul.menu > li:nth-of-type(3) > a.current {
color: #2196f3;
color: #009688;
}
.header > ul.menu > li:nth-of-type(4) > a:hover, .header > ul.menu > li:nth-of-type(4) > a:focus, .header > ul.menu > li:nth-of-type(4) > a.current {
color: #009688;
color: #2196f3;
}
.header > ul.menu > li:nth-of-type(5) > a:hover, .header > ul.menu > li:nth-of-type(5) > a:focus, .header > ul.menu > li:nth-of-type(5) > a.current {
color: #ff9800;
}

/** Content Styles **/
19 changes: 19 additions & 0 deletions app/controllers/access_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
class AccessController < ApplicationController

def login
end

def logout
session[:user_id] = nil
redirect_to :controller => :application
end

private

def attempt_login
user = User.find_by_username(params[:username])
if user && user.authenticate(params[:password])
session[:user_id] = user.id
end
end
end
4 changes: 4 additions & 0 deletions app/controllers/admin_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class AdminController < ApplicationController

def
end
6 changes: 6 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,10 @@ def index

end

private

def logged_in
session[:user_id] != nil
end

end
2 changes: 2 additions & 0 deletions app/helpers/access_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module AccessHelper
end
5 changes: 5 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class User < ActiveRecord::Base

has_secure_password

end
2 changes: 1 addition & 1 deletion app/views/application/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<% content_for :headers do %>
<%= javascript_include_tag 'chart.js' %>
<% end %>
<h1 class="huge center">Hello World!<span>Its very quid pro quo, you hire me and I will make awesome stuff.</span></h1>
<h1 class="huge center">Hello World!<span>Its very quid pro quo, you hire me and I'll make awesome stuff.</span></h1>
<div class="spacer-md"></div>
<p class="center padded">Were do i start? Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Duis vel nisi eu nisi placerat venenatis vitae at sapien. Mauris rutrum risus sapien,
Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<body>
<div class="container">
<div class="header">
<a href="#">Francis Malloch-Boe<span>Yes, i am a Software Engineer</span></a>
<a href="#">Francis Malloch-Boe<span>Yes, I'm a Software Engineer</span></a>

<ul class="menu">
<li>
Expand Down
8 changes: 8 additions & 0 deletions db/migrate/20150819225504_create_users.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class CreateUsers < ActiveRecord::Migration
def change
create_table :users do |t|
t.string :username
t.string :password_digest
end
end
end
21 changes: 21 additions & 0 deletions db/schema.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# encoding: UTF-8
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your
# database schema. If you need to create the application database on another
# system, you should be using db:schema:load, not running all the migrations
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20150819225504) do

create_table "users", force: :cascade do |t|
t.string "username"
t.string "password_digest"
end

end
17 changes: 12 additions & 5 deletions ideas.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
Overview {

About life
Featured Skills
Featured Projects
Featured Hobbies
}
Employment {

Projects {
RSUpdater
RSClient
MyREST
KNN Example
}
Skills {

java etc
}
Education {

Diploma from comuter power
Web architecture cert from uni of mexico
}
Hobbies {
Lots of beautiful pictures here
Expand Down
11 changes: 11 additions & 0 deletions public/javascripts/chart.js

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions test/controllers/access_controller_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require 'test_helper'

class AccessControllerTest < ActionController::TestCase
# test "the truth" do
# assert true
# end
end
11 changes: 11 additions & 0 deletions test/fixtures/users.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html

# This model initially had no columns defined. If you add columns to the
# model remove the '{}' from the fixture names and add the columns immediately
# below each fixture, per the syntax in the comments below
#
one: {}
# column: value
#
two: {}
# column: value
7 changes: 7 additions & 0 deletions test/models/user_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require 'test_helper'

class UserTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end

0 comments on commit ca60314

Please sign in to comment.