24 lines
1.2 KiB
Transact-SQL
24 lines
1.2 KiB
Transact-SQL
CREATE PROCEDURE [dbo].[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
|
||
-- I would have like to have this set to hue default, but alas time got me like: hardcode -_-
|
||
SET @Hue = 0
|
||
COMMIT TRANSACTION
|
||
|
||
RETURN 0
|
||
|