39 lines
No EOL
1.7 KiB
Transact-SQL
39 lines
No EOL
1.7 KiB
Transact-SQL
-----------------------
|
||
-- CREATE A NEW USER --
|
||
-----------------------
|
||
|
||
CREATE PROCEDURE [CreateUser] (
|
||
@email VARCHAR(254),
|
||
@username VARCHAR(32),
|
||
@salt CHAR(32),
|
||
@password CHAR(64),
|
||
@ID INT OUTPUT,
|
||
@Hue INT OUTPUT
|
||
) AS
|
||
BEGIN TRANSACTION
|
||
IF EXISTS (SELECT Email FROM [User] WHERE Email = @email)
|
||
BEGIN
|
||
PRINT 'Email is already registered with an account.'
|
||
ROLLBACK TRANSACTION
|
||
RETURN 1
|
||
END
|
||
|
||
INSERT INTO [User](Email, Username, Salt, [Password]) VALUES (@email, @username, @salt, @password)
|
||
SET @ID = @@IDENTITY
|
||
SELECT @Hue = Hue FROM [User] WHERE ID = @ID
|
||
COMMIT TRANSACTION
|
||
|
||
RETURN 0
|
||
GO
|
||
|
||
-------------------------
|
||
-- GET USER LOGIN INFO --
|
||
-------------------------
|
||
|
||
CREATE PROCEDURE GetUserLogin(
|
||
@email VARCHAR(254)
|
||
) AS
|
||
BEGIN TRANSACTION
|
||
SELECT Id, Salt, [Password], Hue FROM [User] WHERE Email = @email
|
||
COMMIT TRANSACTION
|
||
GO |