EZAccounts 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/EZAccounts.rb +57 -0
- metadata +45 -0
data/lib/EZAccounts.rb
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
class EZAccounts
|
|
2
|
+
require 'sqlite3'
|
|
3
|
+
require 'digest/md5'
|
|
4
|
+
$dbase
|
|
5
|
+
|
|
6
|
+
def initialize(db)
|
|
7
|
+
$dbase= SQLite3::Database.new(db)
|
|
8
|
+
|
|
9
|
+
$dbase.execute("CREATE TABLE IF NOT EXISTS accounts(Id INTEGER PRIMARY KEY,
|
|
10
|
+
email VARCHAR, password VARCHAR)")
|
|
11
|
+
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def RegisterAccount(email,password)
|
|
15
|
+
|
|
16
|
+
@password=Digest::MD5.hexdigest(password)
|
|
17
|
+
|
|
18
|
+
row = $dbase.get_first_row( "select * from accounts where email='#{email}'" )
|
|
19
|
+
|
|
20
|
+
if(row==nil)
|
|
21
|
+
$dbase.execute("insert into accounts (email,password) values('#{email}','#{@password}')")
|
|
22
|
+
|
|
23
|
+
row = $dbase.get_first_row( "select * from accounts where email='#{email}'" )
|
|
24
|
+
|
|
25
|
+
if(row==nil)
|
|
26
|
+
puts "failed to insert"
|
|
27
|
+
return false
|
|
28
|
+
else
|
|
29
|
+
return true
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
else
|
|
33
|
+
return false
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def LoginAccount(email,password)
|
|
38
|
+
@password=Digest::MD5.hexdigest(password)
|
|
39
|
+
row = $dbase.get_first_row( "select password from accounts where email='#{email}'" )
|
|
40
|
+
|
|
41
|
+
if(row==nil)
|
|
42
|
+
return false
|
|
43
|
+
else
|
|
44
|
+
|
|
45
|
+
if(row[0].to_s.eql? @password.to_s)
|
|
46
|
+
return true
|
|
47
|
+
else
|
|
48
|
+
return false
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: EZAccounts
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.6.1
|
|
5
|
+
prerelease:
|
|
6
|
+
platform: ruby
|
|
7
|
+
authors:
|
|
8
|
+
- Darren Breen
|
|
9
|
+
autorequire:
|
|
10
|
+
bindir: bin
|
|
11
|
+
cert_chain: []
|
|
12
|
+
date: 2013-03-27 00:00:00.000000000 Z
|
|
13
|
+
dependencies: []
|
|
14
|
+
description: Easy authentication and registering of accounts. MD5 encrpyted too.
|
|
15
|
+
email: Darren.breen@ballyfad.com
|
|
16
|
+
executables: []
|
|
17
|
+
extensions: []
|
|
18
|
+
extra_rdoc_files: []
|
|
19
|
+
files:
|
|
20
|
+
- lib/EZAccounts.rb
|
|
21
|
+
homepage: http://www.ballyfad.com
|
|
22
|
+
licenses: []
|
|
23
|
+
post_install_message:
|
|
24
|
+
rdoc_options: []
|
|
25
|
+
require_paths:
|
|
26
|
+
- lib
|
|
27
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
28
|
+
none: false
|
|
29
|
+
requirements:
|
|
30
|
+
- - ! '>='
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '0'
|
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
34
|
+
none: false
|
|
35
|
+
requirements:
|
|
36
|
+
- - ! '>='
|
|
37
|
+
- !ruby/object:Gem::Version
|
|
38
|
+
version: '0'
|
|
39
|
+
requirements: []
|
|
40
|
+
rubyforge_project:
|
|
41
|
+
rubygems_version: 1.8.24
|
|
42
|
+
signing_key:
|
|
43
|
+
specification_version: 3
|
|
44
|
+
summary: EZ encrypted database/authentication gem
|
|
45
|
+
test_files: []
|