Revert "fix(webui): handle name already being taken (#2530)"
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				Build / build (pull_request) Successful in 1m11s
				
			
		
		
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	Build / build (pull_request) Successful in 1m11s
				
			This reverts commit 304af514e28e4d6395a6fa6ac83ba2d49c54d5eb.
This commit is contained in:
		
							parent
							
								
									321433420a
								
							
						
					
					
						commit
						f9bbb17f00
					
				@ -2,13 +2,7 @@ import http from "http";
 | 
			
		||||
import https from "https";
 | 
			
		||||
import ws from "ws";
 | 
			
		||||
import { Account } from "@/src/models/loginModel";
 | 
			
		||||
import {
 | 
			
		||||
    createAccount,
 | 
			
		||||
    createNonce,
 | 
			
		||||
    getUsernameFromEmail,
 | 
			
		||||
    isCorrectPassword,
 | 
			
		||||
    isNameTaken
 | 
			
		||||
} from "@/src/services/loginService";
 | 
			
		||||
import { createAccount, createNonce, getUsernameFromEmail, isCorrectPassword } from "@/src/services/loginService";
 | 
			
		||||
import { IDatabaseAccountJson } from "@/src/types/loginTypes";
 | 
			
		||||
import { HydratedDocument } from "mongoose";
 | 
			
		||||
import { logError } from "@/src/utils/logger";
 | 
			
		||||
@ -111,16 +105,14 @@ const wsOnConnect = (ws: ws, req: http.IncomingMessage): void => {
 | 
			
		||||
                    }
 | 
			
		||||
                } else if (data.auth.isRegister) {
 | 
			
		||||
                    const name = await getUsernameFromEmail(data.auth.email);
 | 
			
		||||
                    if (!(await isNameTaken(name))) {
 | 
			
		||||
                        account = await createAccount({
 | 
			
		||||
                            email: data.auth.email,
 | 
			
		||||
                            password: data.auth.password,
 | 
			
		||||
                            ClientType: "webui",
 | 
			
		||||
                            LastLogin: new Date(),
 | 
			
		||||
                            DisplayName: name,
 | 
			
		||||
                            Nonce: createNonce()
 | 
			
		||||
                        });
 | 
			
		||||
                    }
 | 
			
		||||
                    account = await createAccount({
 | 
			
		||||
                        email: data.auth.email,
 | 
			
		||||
                        password: data.auth.password,
 | 
			
		||||
                        ClientType: "webui",
 | 
			
		||||
                        LastLogin: new Date(),
 | 
			
		||||
                        DisplayName: name,
 | 
			
		||||
                        Nonce: createNonce()
 | 
			
		||||
                    });
 | 
			
		||||
                }
 | 
			
		||||
                if (account) {
 | 
			
		||||
                    (ws as IWsCustomData).accountId = account.id;
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user