2
0
Эх сурвалжийг харах

Removed ability to make account via a different service with the same username.

KrisVos130 9 жил өмнө
parent
commit
6163cbba19
1 өөрчлөгдсөн 18 нэмэгдсэн , 4 устгасан
  1. 18 4
      app/app.js

+ 18 - 4
app/app.js

@@ -1345,7 +1345,7 @@ if (Meteor.isServer) {
         }
         }
     });
     });
 
 
-    Accounts.onCreateUser(function(options, user) {
+    Accounts.validateNewUser(function(user) {
         var username;
         var username;
         if (user.services) {
         if (user.services) {
             if (user.services.github) {
             if (user.services.github) {
@@ -1357,11 +1357,25 @@ if (Meteor.isServer) {
             }
             }
         }
         }
         if (Meteor.users.find({"profile.usernameL": username.toLowerCase()}).count() !== 0) {
         if (Meteor.users.find({"profile.usernameL": username.toLowerCase()}).count() !== 0) {
-            return false;
+            throw new Meteor.Error(403, "An account with that username already exists.");
         } else {
         } else {
-            user.profile = {username: username, usernameL: username.toLowerCase(), rank: "default", liked: [], disliked: []};
-            return user;
+            return true;
+        }
+    });
+
+    Accounts.onCreateUser(function(options, user) {
+        var username;
+        if (user.services) {
+            if (user.services.github) {
+                username = user.services.github.username;
+            } else if (user.services.facebook) {
+                username = user.services.facebook.first_name;
+            } else if (user.services.password) {
+                username = user.username;
+            }
         }
         }
+        user.profile = {username: username, usernameL: username.toLowerCase(), rank: "default", liked: [], disliked: []};
+        return user;
     });
     });
 
 
     ServiceConfiguration.configurations.remove({
     ServiceConfiguration.configurations.remove({