achievements_project/sql/CreateUser.sql

24 lines
1.2 KiB
Transact-SQL
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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