achievements_project/sql/CreateUser.sql

25 lines
1.2 KiB
MySQL
Raw Normal View History

2021-02-04 15:56:33 +00:00
<EFBFBD><EFBFBD>CREATE PROCEDURE [dbo].[CreateUser] (
2021-02-06 01:19:11 +00:00
@email VARCHAR(254),
@username VARCHAR(32),
@salt CHAR(32),
@password CHAR(64),
@ID INT OUTPUT,
@Hue INT OUTPUT
2021-02-04 15:56:33 +00:00
) AS
BEGIN TRANSACTION
IF EXISTS (SELECT Email FROM [User] WHERE Email = @email)
BEGIN
2021-02-05 09:59:17 +00:00
PRINT 'Email is already registered with an account.'
2021-02-04 15:56:33 +00:00
ROLLBACK TRANSACTION
RETURN 1
END
2021-02-05 09:59:17 +00:00
INSERT INTO [User](Email, Username, Salt, [Password]) VALUES (@email, @username, @salt, @password)
2021-02-06 01:19:11 +00:00
SET @ID = @@IDENTITY
-- I would have like to have this set to hue default, but alas time got me like: hardcode -_-
SET @Hue = 0
2021-02-04 15:56:33 +00:00
COMMIT TRANSACTION
RETURN 0