Skip to content

Commit 8586b91

Browse files
committed
Merge pull request #6 from rikkotec/master
v0.1.2
2 parents 89a9577 + c5b66c6 commit 8586b91

File tree

10 files changed

+318
-306
lines changed

10 files changed

+318
-306
lines changed

.gitignore

+15-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,15 @@
1-
build
2-
node_modules
1+
## Eclipse ignores
2+
# /.jshintrc
3+
# /.project
4+
5+
## Node.js ignores
6+
/node_modules
7+
/build
8+
9+
## nk-mvc ignores
10+
/libmysql.dll
11+
/ibmysql.lib
12+
13+
## Tool specific files
14+
.gitignore~
15+
.README.md.html

README.md

+155-155
Large diffs are not rendered by default.

app/controllers/home.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ homeController.prototype.index = function( request, response )
3232
pagetitle: 'Hello World!',
3333
username: request.session.get( 'username', 'Guest' ),
3434
testvar:
35-
[,
35+
[
3636
{ 'a': '<b>A Powerful Combination</b>', 'b': '<p>This project comes prepared with the jQuery JavaScript Library, as well as the Bootstrap CSS - which includes their version of Normalize - and JavaScript Libraries. Their links:</p><p><a href="http://jquery.com/" target="_blank">The jQuery website.</a></p><p><a href="http://getbootstrap.com/" target="_blank">The GetBootstrap website.</a></p>.' },
3737
{ 'a': '<b>MySQL</b>', 'b': '<p>This project harnesses the power of MySQL Community Server through nodamysql (nk-mysql on npm), which uses the MySQL Connector C++ to provide efficient and secure data integration. Browse the following links for specifics:</p><p><a href="http://www.mysql.com/about/legal/licensing/foss-exception/" target="_blank">Oracle\'s Free and Open Source (\"FOSS\") License</a>.</p><p><a href="http://github.com/mmod/nodamysql" target="_blank">The nodamysql GitHub.</a></p>' },
38-
{ 'a': '<b>The</b> SJCL', 'b': '<p>This project makes use of the Stanford Javascript Crypto Library, and provides a great starting place for creating a secure and efficient user system. Here are some links to get you started:</p><p><a href="http://crypto.stanford.edu/sjcl/" target="_blank">The Stanford JavaScript Cryto Library website.<a></p><p><a href="https://jswebcrypto.azurewebsites.net/demo.html#/pbkdf2" target="_blank">Getting started with JavaScript and Web Cryptography.</a></p>', 'c': 'yea' },
38+
{ 'a': '<b>The SJCL</b>', 'b': '<p>This project makes use of the Stanford Javascript Crypto Library, and provides a great starting place for creating a secure and efficient user system. Here are some links to get you started:</p><p><a href="http://crypto.stanford.edu/sjcl/" target="_blank">The Stanford JavaScript Cryto Library website.<a></p><p><a href="https://jswebcrypto.azurewebsites.net/demo.html#/pbkdf2" target="_blank">Getting started with JavaScript and Web Cryptography.</a></p>', 'c': 'yea' },
3939
{ 'a': '<b>Business Friendly</b>', 'b': 'This project is created with nodakwaeri (nk on npm), which is provided under the terms of the Apache V2.0 License. You are not required to provide the source to your derived work. Find out more:</p><a href="http://www.apache.org/licenses/LICENSE-2.0" target="_blank">The Apache V2.0 License.</p><a href="http://github.com/mmod/nodakwaeri" target="_blank">The nodakwaeri GitHub.</a><p>.' }
4040
]
4141
// Any additional data you wish to send

app/models/account.js

+100-100
Original file line numberDiff line numberDiff line change
@@ -1,101 +1,101 @@
1-
/**
2-
* package: nk-mvc
3-
* sub-package: models/account
4-
* author: Richard B. Winters <a href="mailto:rik@mmogp.com">rik At Massively Modified</a>
5-
* copyright: 2013-2014 Massively Modified, Inc.
6-
* license: Apache, Version 2.0 <http://www.apache.org/licenses/LICENSE-2.0>
7-
*/
8-
9-
10-
// Deps
11-
var nk = require( 'nk' ),
12-
nk = new nk(); // When we do not pass an argument to the constructor, we get only the core facilities ( .type, .extend, .each, .hash, etc )
13-
14-
15-
/**
16-
* Defines the context model
17-
*
18-
* @since 0.0.1
19-
*/
20-
var accountModel =
21-
{
22-
login: {
23-
authenticate: function( request, response, callback, klay )
24-
{
25-
var user = request.posted.username,
26-
pass = request.posted.password;
27-
pass = nk.hash( { data: pass } );
28-
29-
// Prep the database object
30-
var db = this.dbo();
31-
32-
// Run our query. We will not compare passwords quite yet, as we need the timestamp from the record as part of our salt. This is ok since usernames are unique.
33-
var authenticated = db
34-
.Select( 'users' )
35-
.Where( { username: [ '=', 'text', user ], password: [ '=', 'text', pass ] } )
36-
.Execute();
37-
38-
if( !authenticated[0].username )
39-
{
40-
authenticated = false;
41-
}
42-
43-
// And invoke the callback, passing the result of our query
44-
if( nk.type( callback ) === 'function' )
45-
{ // Asynchronous
46-
callback( request, response, authenticated, klay );
47-
}
48-
else
49-
{ // Synchronous
50-
return authenticated;
51-
}
52-
},
53-
schema: {
54-
/*
55-
* Account Login View Model
56-
*/
57-
// company: [ true, 'text', 'Record Id' ], // We can extend the user facility as we see fit ofc.
58-
type: [ true, 'int', 'Account Type' ],
59-
acl: [ true, 'int', 'Access Level' ],
60-
username: [ true, 'text', 'Username' ],
61-
password: [ true, 'text', 'Password' ],
62-
first: [ true, 'text', 'First Name' ],
63-
last: [ true, 'text', 'Last Name' ],
64-
email: [ true, 'text', 'Email' ]
65-
}
66-
},
67-
loginView: {
68-
schema: {
69-
/*
70-
* Account Login View Model
71-
*/
72-
// company: [ true, 'text', 'Record Id' ], // We can extend the user facility as we see fit ofc.
73-
username: [ true, 'text', 'Username' ],
74-
password: [ true, 'text', 'Password' ],
75-
rememberme: [ true, 'int', 'Remember me' ]
76-
}
77-
},
78-
manageView: {
79-
getUser: function()
80-
{
81-
// This is a placeholder
82-
return { username: 'Guest' };
83-
},
84-
schema: {
85-
/*
86-
* Account/Manage View model
87-
*/
88-
company: [ false, 'int', 'Company' ],
89-
username: [ false, 'text', 'Username' ],
90-
type: [ true, 'text', 'Type' ],
91-
email: [ true, 'text', 'Email' ],
92-
first: [ true, 'text', 'First Name' ],
93-
last: [ true, 'text', 'Last Name' ],
94-
password: [ true, 'text', 'Password' ],
95-
retypepassword: [ true, 'text', 'Re-Type Password' ]
96-
}
97-
}
98-
};
99-
100-
//Export
1+
/**
2+
* package: nk-mvc
3+
* sub-package: models/account
4+
* author: Richard B. Winters <a href="mailto:rik@mmogp.com">rik At Massively Modified</a>
5+
* copyright: 2013-2014 Massively Modified, Inc.
6+
* license: Apache, Version 2.0 <http://www.apache.org/licenses/LICENSE-2.0>
7+
*/
8+
9+
10+
// Deps
11+
var nk = require( 'nk' ),
12+
nk = new nk(); // When we do not pass an argument to the constructor, we get only the core facilities ( .type, .extend, .each, .hash, etc )
13+
14+
15+
/**
16+
* Defines the context model
17+
*
18+
* @since 0.0.1
19+
*/
20+
var accountModel =
21+
{
22+
login: {
23+
authenticate: function( request, response, callback, klay )
24+
{
25+
var user = request.posted.username,
26+
pass = request.posted.password;
27+
pass = nk.hash( { data: pass } );
28+
29+
// Prep the database object
30+
var db = this.dbo();
31+
32+
// Run our query. We will not compare passwords quite yet, as we need the timestamp from the record as part of our salt. This is ok since usernames are unique.
33+
var authenticated = db
34+
.select( 'users' )
35+
.where( { username: [ '=', user ], password: [ '=', pass ] } )
36+
.execute();
37+
38+
if( !authenticated[0].username )
39+
{
40+
authenticated = false;
41+
}
42+
43+
// And invoke the callback, passing the result of our query
44+
if( nk.type( callback ) === 'function' )
45+
{ // Asynchronous
46+
callback( request, response, authenticated, klay );
47+
}
48+
else
49+
{ // Synchronous
50+
return authenticated;
51+
}
52+
},
53+
schema: {
54+
/*
55+
* Account Login View Model
56+
*/
57+
// company: [ true, 'text', 'Record Id' ], // We can extend the user facility as we see fit ofc.
58+
type: [ true, 'int', 'Account Type' ],
59+
acl: [ true, 'int', 'Access Level' ],
60+
username: [ true, 'text', 'Username' ],
61+
password: [ true, 'text', 'Password' ],
62+
first: [ true, 'text', 'First Name' ],
63+
last: [ true, 'text', 'Last Name' ],
64+
email: [ true, 'text', 'Email' ]
65+
}
66+
},
67+
loginView: {
68+
schema: {
69+
/*
70+
* Account Login View Model
71+
*/
72+
// company: [ true, 'text', 'Record Id' ], // We can extend the user facility as we see fit ofc.
73+
username: [ true, 'text', 'Username' ],
74+
password: [ true, 'text', 'Password' ],
75+
rememberme: [ true, 'int', 'Remember me' ]
76+
}
77+
},
78+
manageView: {
79+
getUser: function()
80+
{
81+
// This is a placeholder
82+
return { username: 'Guest' };
83+
},
84+
schema: {
85+
/*
86+
* Account/Manage View model
87+
*/
88+
company: [ false, 'int', 'Company' ],
89+
username: [ false, 'text', 'Username' ],
90+
type: [ true, 'text', 'Type' ],
91+
email: [ true, 'text', 'Email' ],
92+
first: [ true, 'text', 'First Name' ],
93+
last: [ true, 'text', 'Last Name' ],
94+
password: [ true, 'text', 'Password' ],
95+
retypepassword: [ true, 'text', 'Re-Type Password' ]
96+
}
97+
}
98+
};
99+
100+
//Export
101101
module.exports = accountModel;

app/views/account/login.kml

+30-30
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
1-
<div class="panel vestibule-login">
2-
<section id="login">
3-
<h1>[[ pagetitle ]]</h1>
4-
<p></p>
5-
<form action="/account/login" method="post">
6-
<div class="form-group">
7-
[[ html.label( model.username, { "classes": "col-md-offset-2 col-md-2 control-label" } ) ]]
8-
<div class="col-md-6">
9-
[[ html.textbox( yourUserName, { "classes": "form-control", "name": "username" } ) ]]
10-
[[ html.validationmessage( model.username ) ]]
11-
</div>
12-
</div>
13-
<div class="form-group">
14-
[[ html.label( model.password, { "classes": "col-md-offset-2 col-md-2 control-label" } ) ]]
15-
<div class="col-md-6">
16-
[[ html.password( model.password, { "classes": "form-control" } ) ]]
17-
[[ html.validationmessage( model.password ) ]]
18-
</div>
19-
</div>
20-
<div class="col-md-offset-8 col-md-4">
21-
<div class="checkbox">
22-
[[ html.checkbox( model.rememberme ) ]]
23-
[[ html.label( model.rememberme, { "classes": "straight-label" } ) ]]
24-
</div>
25-
</div>
26-
<div class="col-md-offset-8 col-md-4">
27-
<input type="submit" value="Log in" class="btn btn-default" />
28-
</div>
29-
</form>
30-
</section>
1+
<div class="panel vestibule-login">
2+
<section id="login">
3+
<h1>[[ pagetitle ]]</h1>
4+
<p></p>
5+
<form action="/account/login" method="post">
6+
<div class="form-group">
7+
[[ html.label( model.username, { "classes": "col-md-offset-2 col-md-2 control-label" } ) ]]
8+
<div class="col-md-6">
9+
[[ html.textbox( yourUserName, { "classes": "form-control", "name": "username" } ) ]]
10+
[[ html.validationmessage( model.username ) ]]
11+
</div>
12+
</div>
13+
<div class="form-group">
14+
[[ html.label( model.password, { "classes": "col-md-offset-2 col-md-2 control-label" } ) ]]
15+
<div class="col-md-6">
16+
[[ html.password( model.password, { "classes": "form-control" } ) ]]
17+
[[ html.validationmessage( model.password ) ]]
18+
</div>
19+
</div>
20+
<div class="col-md-offset-8 col-md-4">
21+
<div class="checkbox">
22+
[[ html.checkbox( model.rememberme ) ]]
23+
[[ html.label( model.rememberme, { "classes": "straight-label" } ) ]]
24+
</div>
25+
</div>
26+
<div class="col-md-offset-8 col-md-4">
27+
<input type="submit" value="Log in" class="btn btn-default" />
28+
</div>
29+
</form>
30+
</section>
3131
</div>

index.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
/**
2-
* index.js
3-
*
42
* package: nk-mvc
5-
* version: $id$
6-
* author: Richard B. Winters <a href="mailto:rik@mmogp.com">rik At MMOGP</a>
7-
* copyright: 2011-2014 Massively Modified, Inc.
3+
* version: 0.1.1
4+
* author: Richard B. Winters <a href="mailto:rik@mmogp.com">rik At Massively Modified</a>
5+
* copyright: 2013-2014 Massively Modified, Inc.
6+
* license: Apache, Version 2.0 <http://www.apache.org/licenses/LICENSE-2.0>
87
*/
98

109

install/seed.sql

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
CREATE SCHEMA IF NOT EXISTS `nkdev` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci ;
1+
CREATE SCHEMA IF NOT EXISTS `mmogpd` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci ;
22

3-
CREATE TABLE IF NOT EXISTS `nkdev`.`users` (
3+
CREATE TABLE IF NOT EXISTS `mmogpd`.`users` (
44
`id` INT NOT NULL AUTO_INCREMENT,
55
`type` INT NULL,
66
`acl` INT NULL,
@@ -22,12 +22,12 @@ CREATE TABLE IF NOT EXISTS `nkdev`.`users` (
2222
`phone` VARCHAR(45) NULL,
2323
PRIMARY KEY (`id`));
2424

25-
INSERT INTO `nkdev`.`users`
25+
INSERT INTO `mmogpd`.`users`
2626
( `type`, `acl`, `ts`, `company`, `luts`, `username`, `password`, `first`, `last` )
2727
VALUES
2828
( 2, 3, NOW(), 1, NOW(), 'rik', '<ReplaceWithAHashedPassword>', 'Richard', 'Winters' );
2929

30-
CREATE TABLE IF NOT EXISTS `nkdev`.`companies` (
30+
CREATE TABLE IF NOT EXISTS `mmogpd`.`companies` (
3131
`id` INT NOT NULL AUTO_INCREMENT,
3232
`type` INT NULL,
3333
`ts` DATETIME NULL,
@@ -38,15 +38,15 @@ CREATE TABLE IF NOT EXISTS `nkdev`.`companies` (
3838
`description` TEXT NULL,
3939
PRIMARY KEY (`id`));
4040

41-
INSERT INTO `nkdev`.`companies`
41+
INSERT INTO `mmogpd`.`companies`
4242
( `type`, `ts`, `owner`, `luts`, `luby`, `name`, `description` )
4343
VALUES
4444
( 2, NOW(), 1, NOW(), 1, 'Massively Modified, Inc.', 'A massively modified, massively modern corporation!' );
4545

4646

47-
CREATE SCHEMA IF NOT EXISTS `nkpro` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci ;
47+
CREATE SCHEMA IF NOT EXISTS `mmogpp` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci ;
4848

49-
CREATE TABLE IF NOT EXISTS `nkpro`.`users` (
49+
CREATE TABLE IF NOT EXISTS `mmogpp`.`users` (
5050
`id` INT NOT NULL AUTO_INCREMENT,
5151
`type` INT NULL,
5252
`acl` INT NULL,
@@ -68,13 +68,13 @@ CREATE TABLE IF NOT EXISTS `nkpro`.`users` (
6868
`phone` VARCHAR(45) NULL,
6969
PRIMARY KEY (`id`));
7070

71-
INSERT INTO `nkpro`.`users`
71+
INSERT INTO `mmogpp`.`users`
7272
( `type`, `acl`, `ts`, `company`, `luts`, `username`, `password`, `first`, `last` )
7373
VALUES
7474
( 2, 3, NOW(), 1, NOW(), 'rik', '<ReplaceWithAHashedPassword>', 'Richard', 'Winters' );
7575

7676

77-
CREATE TABLE IF NOT EXISTS `nkpro`.`companies` (
77+
CREATE TABLE IF NOT EXISTS `mmogpp`.`companies` (
7878
`id` INT NOT NULL AUTO_INCREMENT,
7979
`type` INT NULL,
8080
`ts` DATETIME NULL,
@@ -85,7 +85,7 @@ CREATE TABLE IF NOT EXISTS `nkpro`.`companies` (
8585
`description` TEXT NULL,
8686
PRIMARY KEY (`id`));
8787

88-
INSERT INTO `nkpro`.`companies`
88+
INSERT INTO `mmogpp`.`companies`
8989
( `type`, `ts`, `owner`, `luts`, `luby`, `name`, `description` )
9090
VALUES
9191
( 2, NOW(), 1, NOW(), 1, 'Massively Modified, Inc.', 'A massively modified, massively modern corporation!' );

libmysql.dll

-4.5 MB
Binary file not shown.

libmysql.lib

-25.2 KB
Binary file not shown.

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nk-mvc",
3-
"version": "0.1.0",
3+
"version": "0.1.2",
44
"description": "The Hello World project template for nodakwaeri(nk) on Node.js.",
55
"main": "index.js",
66
"scripts": {
@@ -12,7 +12,7 @@
1212
},
1313
"dependencies": {
1414
"nk": "0.2.x",
15-
"nk-mysql": "0.1.x"
15+
"nk-mysql": "0.2.x"
1616
},
1717
"keywords": [
1818
"nodakwaeri",

0 commit comments

Comments
 (0)