Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Add
insert_user()
and change_pass()
.
- Loading branch information
Showing
7 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
-- Deploy change_pass | ||
-- requires: users | ||
-- requires: appschema | ||
|
||
BEGIN; | ||
|
||
CREATE OR REPLACE FUNCTION flipr.change_pass( | ||
nick TEXT, | ||
oldpass TEXT, | ||
newpass TEXT | ||
) RETURNS BOOLEAN LANGUAGE plpgsql SECURITY DEFINER AS $$ | ||
BEGIN | ||
UPDATE flipr.users | ||
SET password = md5($3) | ||
WHERE nickname = $1 | ||
AND password = md5($2); | ||
RETURN FOUND; | ||
END; | ||
$$; | ||
|
||
COMMIT; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
-- Deploy insert_user | ||
-- requires: users | ||
-- requires: appschema | ||
|
||
BEGIN; | ||
|
||
CREATE OR REPLACE FUNCTION flipr.insert_user( | ||
nickname TEXT, | ||
password TEXT | ||
) RETURNS VOID LANGUAGE SQL SECURITY DEFINER AS $$ | ||
INSERT INTO flipr.users VALUES($1, md5($2)); | ||
$$; | ||
|
||
COMMIT; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
-- Revert change_pass | ||
|
||
BEGIN; | ||
|
||
DROP FUNCTION flipr.change_pass(TEXT, TEXT, TEXT); | ||
|
||
COMMIT; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
-- Revert insert_user | ||
|
||
BEGIN; | ||
|
||
DROP FUNCTION flipr.insert_user(TEXT, TEXT); | ||
|
||
COMMIT; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
-- Verify change_pass | ||
|
||
BEGIN; | ||
|
||
SELECT has_function_privilege('flipr.change_pass(text, text, text)', 'execute'); | ||
|
||
ROLLBACK; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
-- Verify insert_user | ||
|
||
BEGIN; | ||
|
||
SELECT has_function_privilege('flipr.insert_user(text, text)', 'execute'); | ||
|
||
ROLLBACK; |