Sha256: f4c8b337299c267b420a8c44ea85de56df7192f603031237307cded51c0444af

Contents?: true

Size: 969 Bytes

Versions: 2

Compression:

Stored size: 969 Bytes

Contents

#
# Blogaze
# Copyright (C) 2011-2013 Jack Polgar
#
# Blogaze is released under the BSD 3-clause license.
# @license http://opensource.org/licenses/BSD-3-Clause
#

module Blogaze
  module Controllers
    class Users < Controller
      map '/users'

      def new
        @title = "Register - #{@settings[:title]}"
        @user = ::Blogaze::Models::User.new
        respond(view_file('users/new'))
      end

      def create
        @title = "Register - #{@settings[:title]}"
        data = {
          :username => request[:username],
          :password => request[:password],
          :email => request[:email],
          :group_id => 3
        }

        @user = ::Blogaze::Models::User.new(data)

        if @user.valid?
          @user.save
          flash[:success] = "Account created, you may now login"
          redirect '/login'
        else
          respond(view_file('users/new'))
        end
      end
    end # Users
  end # Controllers
end # Blogaze

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
blogaze-0.0.3 lib/blogaze/controllers/users.rb
blogaze-0.0.2 lib/blogaze/controllers/users.rb