Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
persona
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hexang 息壤平台
persona
Commits
a5a73ece
Commit
a5a73ece
authored
13 years ago
by
Lloyd Hilaiel
Browse files
Options
Downloads
Patches
Plain Diff
(mysql driver) implement stageUser, isStaged, and emailKnown
parent
df0ed4e7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
browserid/lib/db.js
+1
-0
1 addition, 0 deletions
browserid/lib/db.js
browserid/lib/db_mysql.js
+56
-14
56 additions, 14 deletions
browserid/lib/db_mysql.js
with
57 additions
and
14 deletions
browserid/lib/db.js
+
1
−
0
View file @
a5a73ece
...
...
@@ -70,6 +70,7 @@ exports.onReady = function(f) {
'
cancelAccount
'
].
forEach
(
function
(
fn
)
{
exports
[
fn
]
=
function
()
{
console
.
log
(
fn
);
checkReady
();
driver
[
fn
].
apply
(
undefined
,
arguments
);
};
...
...
This diff is collapsed.
Click to expand it.
browserid/lib/db_mysql.js
+
56
−
14
View file @
a5a73ece
...
...
@@ -8,13 +8,21 @@
*
* +--- user ------+ +--- email ----+ +----- key ------+
* |*int id | <-\ |*int id | <-\ |*int id |
* |
text
passw
or
d | \- |*int user | \-- |*int email |
* +---------------+ |
text
address
|
|
text key
|
* |
string
passwd | \- |*int user | \-- |*int email |
* +---------------+ |
*string
address |
string pubkey
|
* +--------------+ | int expires |
* +----------------+
*
*
*
* +------ staged ----------+
* |*string secret |
* | bool new_acct |
* | string existing |
* | string email |
* | string pubkey |
* | string passwd |
* | timestamp ts |
* +------------------------+
*/
const
...
...
@@ -27,9 +35,10 @@ var client = undefined;
var
drop_on_close
=
undefined
;
const
schemas
=
[
"
CREATE TABLE IF NOT EXISTS user ( id INTEGER PRIMARY KEY, password TEXT );
"
,
"
CREATE TABLE IF NOT EXISTS email ( id INTEGER PRIMARY KEY, user INTEGER, address VARCHAR(255) UNIQUE );
"
,
"
CREATE TABLE IF NOT EXISTS pubkey ( id INTEGER PRIMARY KEY, email INTEGER, content TEXT, expiry INTEGER );
"
"
CREATE TABLE IF NOT EXISTS user ( id INTEGER PRIMARY KEY, passwd VARCHAR(64) );
"
,
"
CREATE TABLE IF NOT EXISTS email ( id INTEGER PRIMARY KEY, user INTEGER, address VARCHAR(255) UNIQUE, INDEX(address) );
"
,
"
CREATE TABLE IF NOT EXISTS pubkey ( id INTEGER PRIMARY KEY, email INTEGER, content TEXT, expiry INTEGER );
"
,
"
CREATE TABLE IF NOT EXISTS staged ( secret VARCHAR(48) PRIMARY KEY, new_acct BOOL, existing VARCHAR(255), email VARCHAR(255) UNIQUE, INDEX(email), pubkey TEXT, passwd VARCHAR(64), ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP);
"
];
// open & create the mysql database
...
...
@@ -108,12 +117,22 @@ exports.close = function(cb) {
}
};
exports
.
emailKnown
=
function
()
{
throw
"
not implemented
"
;
exports
.
emailKnown
=
function
(
email
,
cb
)
{
client
.
query
(
"
SELECT COUNT(*) as N FROM email WHERE address = ?
"
,
[
email
],
function
(
err
,
results
,
fields
)
{
cb
(
results
[
'
N
'
]
>
0
);
}
);
}
exports
.
isStaged
=
function
()
{
throw
"
not implemented
"
;
exports
.
isStaged
=
function
(
email
,
cb
)
{
client
.
query
(
"
SELECT COUNT(*) as N FROM staged WHERE email = ?
"
,
[
email
],
function
(
err
,
results
,
fields
)
{
cb
(
results
[
'
N
'
]
>
0
);
}
);
}
exports
.
emailsBelongToSameAccount
=
function
()
{
...
...
@@ -124,16 +143,39 @@ exports.addKeyToEmail = function() {
throw
"
not implemented
"
;
}
exports
.
stageUser
=
function
()
{
throw
"
not implemented
"
;
exports
.
stageUser
=
function
(
obj
,
cb
)
{
var
secret
=
secrets
.
generate
(
48
);
// overwrite previously staged users
client
.
query
(
'
INSERT INTO staged (secret, new_acct, email, pubkey, passwd) VALUES(?,TRUE,?,?,?)
'
+
'
ON DUPLICATE KEY UPDATE secret=?, existing="", new_acct=TRUE, pubkey=?, passwd=?
'
,
[
secret
,
obj
.
email
,
obj
.
pubkey
,
obj
.
hash
,
secret
,
obj
.
pubkey
,
obj
.
hash
],
function
(
err
)
{
if
(
err
)
cb
(
undefined
,
err
);
else
cb
(
secret
);
});
}
exports
.
stageEmail
=
function
()
{
throw
"
not implemented
"
;
}
exports
.
gotVerificationSecret
=
function
()
{
throw
"
not implemented
"
;
exports
.
gotVerificationSecret
=
function
(
secret
,
cb
)
{
client
.
query
(
"
SELECT * FROM staged WHERE secret = ?
"
,
[
secret
],
function
(
err
,
rows
)
{
if
(
err
)
cb
(
err
);
else
if
(
rows
.
length
===
0
)
cb
(
"
unknown secret
"
);
else
{
var
o
=
rows
[
0
];
// delete the record
client
.
query
(
"
DELETE LOW_PRIORITY FROM staged WHERE secret = ?
"
,
[
secret
]);
// XXX: perform add acct or email depending on value of new_acct BOOL
console
.
log
(
o
);
}
}
);
}
exports
.
checkAuth
=
function
()
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment